Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-10-06 08:44:23
Exec Total Coverage
Lines: 1669 4267 39.1%
Functions: 130 334 38.9%
Branches: 924 2862 32.3%

Line Branch Exec Source
1 #include "zc/zc_sys.h"
2
3 #include "allegro/gfx.h"
4 #include "allegro5/joystick.h"
5 #include "base/qrs.h"
6 #include "base/dmap.h"
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <cstring>
10 #include <math.h>
11 #include <map>
12 #include <filesystem>
13 #include <ctype.h>
14 #include <sstream>
15 #include "base/zc_alleg.h"
16 #include "gamedata.h"
17 #include "zc/zc_init.h"
18 #include "init.h"
19 #include "zc/replay.h"
20 #include "zc/cheats.h"
21 #include "zc/render.h"
22 #include "base/zc_math.h"
23 #include "base/zapp.h"
24 #include "dialog/cheatkeys.h"
25 #include "metadata/metadata.h"
26 #include "zc/zelda.h"
27 #include "zc/saves.h"
28 #include "tiles.h"
29 #include "base/colors.h"
30 #include "pal.h"
31 #include "base/zsys.h"
32 #include "qst.h"
33 #include "zc/zc_sys.h"
34 #include "play_midi.h"
35 #include "jwin_a5.h"
36 #include "base/jwinfsel.h"
37 #include "base/gui.h"
38 #include "midi.h"
39 #include "subscr.h"
40 #include "zc/maps.h"
41 #include "sprite.h"
42 #include "zc/guys.h"
43 #include "zc/hero.h"
44 #include "zc/title.h"
45 #include "particles.h"
46 #include "zcmusic.h"
47 #include "zconsole.h"
48 #include "zc/ffscript.h"
49 #include "dialog/info.h"
50 #include "dialog/alert.h"
51 #include "zc/combos.h"
52 #include "zc/jit.h"
53 #include "zc/zc_subscr.h"
54 #include <fmt/format.h>
55 #include "zinfo.h"
56 #include "base/misctypes.h"
57
58 #ifdef __EMSCRIPTEN__
59 #include "base/emscripten_utils.h"
60 #endif
61
62 using namespace std::chrono_literals;
63
64 extern FFScript FFCore;
65 extern bool Playing;
66 int32_t sfx_voice[WAV_COUNT];
67 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
68 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
69 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c);
70
71 extern byte monochrome_console;
72
73 extern HeroClass Hero;
74 extern zcmodule moduledata;
75 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
76 extern particle_list particles;
77 extern int32_t loadlast;
78 extern char *sfx_string[WAV_COUNT];
79 byte use_dwm_flush;
80 byte use_save_indicator;
81 int32_t paused_midi_pos = 0;
82 byte midi_suspended = 0;
83 byte zc_192b163_warp_compatibility;
84 char modulepath[2048];
85 bool epilepsyFlashReduction;
86 signed char pause_in_background_menu_init = 0;
87 byte pause_in_background = 0;
88 bool is_sys_pal = false;
89 static bool load_control_called_this_frame;
90 extern PALETTE* hw_palette;
91 extern bool update_hw_pal;
92 extern const char* dmaplist(int32_t index, int32_t* list_size);
93 int32_t getnumber(const char *prompt,int32_t initialval);
94
95 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
96 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
97
98 static const char *qst_module_name = "current_module";
99 #ifdef ALLEGRO_LINUX
100 static const char *samplepath = "samplesoundset/patches.dat";
101 #endif
102 char qst_files_path[2048];
103
104 #ifdef _MSC_VER
105 #define getcwd _getcwd
106 #endif
107
108 bool rF11();
109 bool rI();
110 bool rQ();
111 bool zc_key_pressed();
112
113 #ifdef _WIN32
114
115 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
116 extern "C"
117 {
118 typedef HRESULT(WINAPI *t_DwmFlush)();
119 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
120 }
121
122 void do_DwmFlush()
123 {
124 static HMODULE shell = LoadLibrary("dwmapi.dll");
125
126 if(!shell)
127 return;
128
129 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
130 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
131
132 BOOL enabled;
133 isEnabled(&enabled);
134
135 if(isEnabled)
136 flush();
137 }
138
139 #endif // _WIN32
140
141 83751 bool flash_reduction_enabled(bool check_qr)
142 {
143
4/4
✓ Branch 0 taken 81530 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 81074 times.
✓ Branch 3 taken 83295 times.
83751 return (check_qr && get_qr(qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
144 }
145
146 // Dialogue largening
147 void large_dialog(DIALOG *d)
148 {
149 large_dialog(d, 1.5);
150 }
151
152 void large_dialog(DIALOG *d, float RESIZE_AMT)
153 {
154 if(!d[0].d1)
155 {
156 d[0].d1 = 1;
157 int32_t oldwidth = d[0].w;
158 int32_t oldheight = d[0].h;
159 int32_t oldx = d[0].x;
160 int32_t oldy = d[0].y;
161 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
162 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
163 d[0].w = int32_t(d[0].w*RESIZE_AMT);
164 d[0].h = int32_t(d[0].h*RESIZE_AMT);
165
166 for(int32_t i=1; d[i].proc !=NULL; i++)
167 {
168 // Place elements horizontally
169 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
170 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
171
172 if(d[i].proc != d_stringloader)
173 {
174 if(d[i].proc==d_bitmap_proc)
175 {
176 d[i].w *= 2;
177 }
178 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
179 }
180
181 // Place elements vertically
182 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
183 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
184
185 // Vertically resize elements
186 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
187 {
188 d[i].h = int32_t((double)d[i].h*1.5);
189 }
190 else if(d[i].proc == jwin_droplist_proc || d[i].proc == d_joylist_proc)
191 {
192 d[i].y += int32_t((double)d[i].h*0.25);
193 d[i].h = int32_t((double)d[i].h*1.25);
194 }
195 else if(d[i].proc==d_bitmap_proc)
196 {
197 d[i].h *= 2;
198 }
199 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
200
201 // Fix frames
202 if(d[i].proc == jwin_frame_proc)
203 {
204 d[i].x++;
205 d[i].y++;
206 d[i].w-=4;
207 d[i].h-=4;
208 }
209 }
210 }
211
212 for(int32_t i=1; d[i].proc!=NULL; i++)
213 {
214 if(d[i].proc==jwin_slider_proc)
215 continue;
216
217 // Bigger font
218 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc && d[i].proc != d_joylist_proc);
219
220 if(!d[i].dp2 && bigfontproc)
221 {
222 d[i].dp2 = get_zc_font(font_lfont_l);
223 }
224 else if(!bigfontproc)
225 {
226 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
227 }
228
229 // Make checkboxes work
230 if(d[i].proc == jwin_check_proc)
231 d[i].proc = jwin_checkfont_proc;
232 else if(d[i].proc == jwin_radio_proc)
233 d[i].proc = jwin_radiofont_proc;
234 }
235
236 jwin_center_dialog(d);
237 }
238
239
240 /**********************************/
241 /******** System functions ********/
242 /**********************************/
243
244 static char cfg_sect[] = "zeldadx"; //We need to rename this.
245 static char ctrl_sect[] = "Controls";
246 static char sfx_sect[] = "Volume";
247
248 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
249 {
250 return D_O_K;
251 }
252
253 bool is_reserved_key(int c)
254 {
255 switch(c)
256 {
257 case KEY_ESC:
258 return true;
259 }
260 return false;
261 }
262 bool is_reserved_keycombo(int c, int modflag)
263 {
264 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
265 return true;
266 return false;
267 }
268 bool checkcheat(Cheat cheat)
269 {
270 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
271 return true; //Main key pressed
272 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
273 return true; //Alt key pressed
274 return false;
275 }
276 115 void load_default_cheatkeys()
277 {
278 115 memset(cheatkeys, 0, sizeof(cheatkeys));
279 115 cheatkeys[Cheat::Life][0] = KEY_H;
280 115 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
281 115 cheatkeys[Cheat::Magic][0] = KEY_M;
282 115 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
283 115 cheatkeys[Cheat::Rupies][0] = KEY_R;
284 115 cheatkeys[Cheat::Bombs][0] = KEY_B;
285 115 cheatkeys[Cheat::Arrows][0] = KEY_A;
286 115 cheatkeys[Cheat::Clock][0] = KEY_I;
287 115 cheatkeys[Cheat::Walls][0] = KEY_F11;
288 115 cheatkeys[Cheat::Fast][0] = KEY_Q;
289 115 cheatkeys[Cheat::Light][0] = KEY_L;
290 115 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
291 115 cheatkeys[Cheat::Kill][0] = KEY_K;
292 115 cheatkeys[Cheat::GoTo][0] = KEY_G;
293 115 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
294 115 cheatkeys[Cheat::ShowL0][0] = KEY_0;
295 115 cheatkeys[Cheat::ShowL1][0] = KEY_1;
296 115 cheatkeys[Cheat::ShowL2][0] = KEY_2;
297 115 cheatkeys[Cheat::ShowL3][0] = KEY_3;
298 115 cheatkeys[Cheat::ShowL4][0] = KEY_4;
299 115 cheatkeys[Cheat::ShowL5][0] = KEY_5;
300 115 cheatkeys[Cheat::ShowL6][0] = KEY_6;
301 115 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
302 115 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
303 115 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
304 115 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
305 115 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
306 115 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
307 115 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
308 115 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
309 115 }
310 115 void load_game_configs()
311 {
312 115 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
313 115 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
314 115 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
315 115 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
316 115 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
317 115 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
318 115 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
319 115 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
320 115 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
321 115 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
322 115 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
323 115 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
324 115 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
325 115 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
326 115 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
327
328 //cheat modifier keya
329 115 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
330 115 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
331 115 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
332 115 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
333
334 //cheat keys
335 115 load_default_cheatkeys();
336 char buf[256];
337
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 4025 times.
4140 for(size_t q = 1; q < Cheat::Last; ++q)
338 {
339
1/2
✓ Branch 0 taken 4025 times.
✗ Branch 1 not taken.
4025 if(!bindable_cheat((Cheat)q)) continue;
340 4025 std::string cheatname = cheat_to_string((Cheat)q);
341
1/2
✓ Branch 0 taken 4025 times.
✗ Branch 1 not taken.
4025 util::lowerstr(cheatname);
342 4025 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
343
1/2
✓ Branch 0 taken 4025 times.
✗ Branch 1 not taken.
4025 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
344 4025 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
345
1/2
✓ Branch 0 taken 4025 times.
✗ Branch 1 not taken.
4025 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
346 4025 }
347
348
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
349 joystick_index = 0;
350
351 115 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
352 115 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
353 115 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
354 115 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
355 115 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
356 115 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
357 115 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
358 115 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
359 115 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
360 115 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
361
362 115 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
363 115 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
364 115 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
365 115 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
366
367 115 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
368 115 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
369 115 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
370 115 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
371 115 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
372 115 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
373 115 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
374 115 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
375 115 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
376 115 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
377 115 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
378
379 115 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
380 115 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
381 115 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
382 115 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
383
384 115 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
385
386 115 digi_volume = zc_get_config(sfx_sect,"digi",248);
387 115 midi_volume = zc_get_config(sfx_sect,"midi",255);
388 115 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
389 115 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
390 115 pan_style = zc_get_config(sfx_sect,"pan",1);
391 // 1 <= zcmusic_bufsz <= 128
392 115 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
393 115 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
394 115 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
395 115 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
396 115 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
397 115 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
398 115 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
399 #ifdef __EMSCRIPTEN__
400 if (em_is_mobile()) NameEntryMode = 2;
401 #endif
402 115 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
403 115 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
404 115 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
405 115 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
406 115 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
407
408 //default - scale x2, 640 x 480
409 115 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
410 115 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
411 115 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
412 115 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
413 115 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
414 115 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
415 115 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
416
417 115 loadlast = zc_get_config(cfg_sect,"load_last",0);
418
419 115 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
420
421 115 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
422
423 115 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
424 115 info_opacity = zc_get_config("zc","debug_info_opacity",255);
425 #ifdef _WIN32
426 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
427 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
428 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
429 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
430
431 // This one's for Aero
432 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
433
434 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
435 #else //UNIX
436 115 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
437 115 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
438 115 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
439 #endif
440 115 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
441 115 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
442
443 115 strcpy(qstdir,zc_get_config(cfg_sect,"quest_dir","quests"));
444 115 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
445 115 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
446 115 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
447 115 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
448 115 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
449 115 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
450 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
451 115 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
452 115 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
453 115 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
454 115 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
455 115 }
456
457 void save_control_configs(bool kb)
458 {
459 if(kb)
460 {
461 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
462 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
463 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
464 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
465
466 if (!replay_is_replaying())
467 {
468 zc_set_config(ctrl_sect,"key_a",Akey);
469 zc_set_config(ctrl_sect,"key_b",Bkey);
470 zc_set_config(ctrl_sect,"key_s",Skey);
471 zc_set_config(ctrl_sect,"key_l",Lkey);
472 zc_set_config(ctrl_sect,"key_r",Rkey);
473 zc_set_config(ctrl_sect,"key_p",Pkey);
474 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
475 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
476 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
477 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
478 zc_set_config(ctrl_sect,"key_up", DUkey);
479 zc_set_config(ctrl_sect,"key_down", DDkey);
480 zc_set_config(ctrl_sect,"key_left", DLkey);
481 zc_set_config(ctrl_sect,"key_right",DRkey);
482 }
483 }
484 else
485 {
486 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
487 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
488 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
489 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
490 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
491 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
492 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
493 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
494 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
495 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
496 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
497 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
498 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
499 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
500
501 zc_set_config(ctrl_sect,"btn_a",Abtn);
502 zc_set_config(ctrl_sect,"btn_b",Bbtn);
503 zc_set_config(ctrl_sect,"btn_s",Sbtn);
504 zc_set_config(ctrl_sect,"btn_m",Mbtn);
505 zc_set_config(ctrl_sect,"btn_l",Lbtn);
506 zc_set_config(ctrl_sect,"btn_r",Rbtn);
507 zc_set_config(ctrl_sect,"btn_p",Pbtn);
508 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
509 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
510 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
511 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
512
513 zc_set_config(ctrl_sect,"btn_up",DUbtn);
514 zc_set_config(ctrl_sect,"btn_down",DDbtn);
515 zc_set_config(ctrl_sect,"btn_left",DLbtn);
516 zc_set_config(ctrl_sect,"btn_right",DRbtn);
517 }
518 }
519
520 void save_cheatkeys()
521 {
522 char buf[256];
523 for(size_t q = 1; q < Cheat::Last; ++q)
524 {
525 if(!bindable_cheat((Cheat)q)) continue;
526 std::string cheatname = cheat_to_string((Cheat)q);
527 util::lowerstr(cheatname);
528 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
529 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
530 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
531 if(cheatkeys[q][1])
532 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
533 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
534 }
535 }
536
537 void save_game_configs()
538 {
539 packfile_password("");
540
541 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
542
543 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
544 {
545 int o_window_x, o_window_y;
546 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
547 zc_set_config(cfg_sect,"window_x",o_window_x);
548 zc_set_config(cfg_sect,"window_y",o_window_y);
549 }
550
551 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
552 {
553 double monitor_scale = zc_get_monitor_scale();
554 window_width = al_get_display_width(all_get_display()) / monitor_scale;
555 window_height = al_get_display_height(all_get_display()) / monitor_scale;
556 zc_set_config(cfg_sect,"window_width",window_width);
557 zc_set_config(cfg_sect,"window_height",window_height);
558 }
559
560 zc_set_config(cfg_sect,"load_last",loadlast);
561 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
562
563 flush_config_file();
564 #ifdef __EMSCRIPTEN__
565 em_sync_fs();
566 #endif
567 }
568
569 //----------------------------------------------------------------
570
571 // Timers
572
573 30083 void fps_callback()
574 {
575 30083 lastfps=framecnt;
576 30083 dword tempsecs = fps_secs;
577 30083 ++tempsecs;
578 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
579 30083 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
580 30083 ++fps_secs;
581 30083 framecnt=0;
582 30083 }
583
584 END_OF_FUNCTION(fps_callback)
585
586 115 int32_t Z_init_timers()
587 {
588 static bool didit = false;
589 const static char *err_str = "Couldn't allocate timer";
590 115 err_str = err_str; //Unused variable warning
591
592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(didit)
593 return 1;
594
595 115 didit = true;
596
597 LOCK_VARIABLE(lastfps);
598 LOCK_VARIABLE(framecnt);
599 LOCK_FUNCTION(fps_callback);
600
601
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
602 return 0;
603
604 115 return 1;
605 115 }
606
607 void Z_remove_timers()
608 {
609 remove_int(fps_callback);
610 }
611
612 //----------------------------------------------------------------
613
614 void go()
615 {
616 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
617 }
618
619 void comeback()
620 {
621 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
622 }
623
624 void dump_pal(BITMAP *dest)
625 {
626 for(int32_t i=0; i<256; i++)
627 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
628 }
629
630 //----------------------------------------------------------------
631
632 int game_mouse_index = ZCM_BLANK;
633 static bool system_mouse = false;
634 28 bool sys_mouse()
635 {
636 28 system_mouse = true;
637 28 return MouseSprite::set(ZCM_NORMAL);
638 }
639 557 bool game_mouse()
640 {
641 557 system_mouse = false;
642 557 return MouseSprite::set(game_mouse_index);
643 }
644 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
645 {
646 if(!bmp)
647 return;
648 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
649 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
650 if(bmp->w == scaledw && bmp->h == scaledh)
651 user_scale = false;
652 if(user_scale || sys_recolor)
653 {
654 if(!user_scale) scale = 1;
655 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
656 if(user_scale)
657 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
658 else
659 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
660 if(sys_recolor)
661 recolor_mouse(tmpbmp);
662 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
663 destroy_bitmap(tmpbmp);
664 }
665 else
666 {
667 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
668 }
669 }
670
671 //Handles converting the mouse sprite from the .dat file
672 void recolor_mouse(BITMAP* bmp)
673 {
674 for(int32_t x = 0; x < bmp->w; ++x)
675 {
676 for(int32_t y = 0; y < bmp->h; ++y)
677 {
678 int32_t color = getpixel(bmp, x, y);
679 switch(color)
680 {
681 case dvc(1):
682 color = jwin_pal[jcCURSORMISC];
683 break;
684 case dvc(2):
685 color = jwin_pal[jcCURSOROUTLINE];
686 break;
687 case dvc(3):
688 color = jwin_pal[jcCURSORLIGHT];
689 break;
690 case dvc(5):
691 color = jwin_pal[jcCURSORDARK];
692 break;
693 default:
694 continue;
695 }
696 putpixel(bmp, x, y, color);
697 }
698 }
699 }
700 void load_mouse()
701 {
702 PALETTE pal;
703 BITMAP* cursor_bitmap = load_bitmap("assets/cursor.bmp", pal);
704 if (!cursor_bitmap)
705 Z_error_fatal("Missing required file %s\n", "assets/cursor.bmp");
706
707 enter_sys_pal();
708 MouseSprite::set(-1);
709 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
710 int32_t sz = 16*scale;
711 for(int32_t j = 0; j < 1; ++j)
712 {
713 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
714 if(zcmouse[j])
715 destroy_bitmap(zcmouse[j]);
716 zcmouse[j] = create_bitmap_ex(8,sz,sz);
717 clear_bitmap(zcmouse[j]);
718 clear_bitmap(tmpbmp);
719 blit(cursor_bitmap,tmpbmp,1,j*17+1,0,0,16,16);
720 recolor_mouse(tmpbmp);
721 if(sz!=16)
722 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
723 else
724 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
725 destroy_bitmap(tmpbmp);
726 }
727 if(!hw_palette) hw_palette = &RAMpal;
728 zc_set_palette(*hw_palette);
729
730 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
731 clear_bitmap(blankmouse);
732
733 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
734 MouseSprite::assign(ZCM_BLANK, blankmouse);
735 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
736
737 //Reload the mouse
738 if(system_mouse)
739 sys_mouse();
740 else game_mouse();
741
742 destroy_bitmap(blankmouse);
743 destroy_bitmap(cursor_bitmap);
744 exit_sys_pal();
745 }
746
747 // sets the video mode and initializes the palette and mouse sprite
748 115 bool game_vid_mode(int32_t mode,int32_t wait)
749 {
750
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if (is_headless())
751 115 return true;
752
753 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
754 {
755 return false;
756 }
757
758 scrx = (resx-320)>>1;
759 scry = (resy-240)>>1;
760 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
761 zcmouse[q] = NULL;
762 load_mouse();
763
764 for(int32_t i=240; i<256; i++)
765 RAMpal[i]=pal_gui[i];
766
767 zc_set_palette(RAMpal);
768 clear_to_color(screen,BLACK);
769
770 rest(wait);
771 return true;
772 115 }
773
774 8 void null_quest()
775 {
776 char qstdat_string[2048];
777 8 strcpy(qstdat_string, "modules/classic/default.qst");
778
779 #ifdef __EMSCRIPTEN__
780 // The quest template data file is not included because it's really big and isn't really needed
781 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
782 // which is much smaller.
783 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
784 #endif
785
786 8 byte skip_flags[4] = { 0 };
787
788 8 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,skip_flags,0,false);
789 8 }
790
791 8 void init_NES_mode()
792 {
793 8 null_quest();
794 8 }
795
796 //----------------------------------------------------------------
797
798 qword trianglelines[16]=
799 {
800 0x0000000000000000ULL,
801 0xFD00000000000000ULL,
802 0xFDFD000000000000ULL,
803 0xFDFDFD0000000000ULL,
804 0xFDFDFDFD00000000ULL,
805 0xFDFDFDFDFD000000ULL,
806 0xFDFDFDFDFDFD0000ULL,
807 0xFDFDFDFDFDFDFD00ULL,
808 0xFDFDFDFDFDFDFDFDULL,
809 0x00FDFDFDFDFDFDFDULL,
810 0x0000FDFDFDFDFDFDULL,
811 0x000000FDFDFDFDFDULL,
812 0x00000000FDFDFDFDULL,
813 0x0000000000FDFDFDULL,
814 0x000000000000FDFDULL,
815 0x00000000000000FDULL,
816 };
817
818 word screen_triangles[28][32];
819 /*
820 qword triangles[4][16]= //[direction][value]
821 {
822 {
823 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
824 },
825 {
826 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
827 },
828 {
829 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
830 },
831 {
832 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
833 }
834 };
835 */
836
837
838 /*
839 byte triangles[4][16][8]= //[direction][value][line]
840 {
841 {
842 {
843 0, 0, 0, 0, 0, 0, 0, 0
844 },
845 {
846 1, 0, 0, 0, 0, 0, 0, 0
847 },
848 {
849 2, 1, 0, 0, 0, 0, 0, 0
850 },
851 {
852 3, 2, 1, 0, 0, 0, 0, 0
853 },
854 {
855 4, 3, 2, 1, 0, 0, 0, 0
856 },
857 {
858 5, 4, 3, 2, 1, 0, 0, 0
859 },
860 {
861 6, 5, 4, 3, 2, 1, 0, 0
862 },
863 {
864 7, 6, 5, 4, 3, 2, 1, 0
865 },
866 {
867 8, 7, 6, 5, 4, 3, 2, 1
868 },
869 {
870 8, 8, 7, 6, 5, 4, 3, 2
871 },
872 {
873 8, 8, 8, 7, 6, 5, 4, 3
874 },
875 {
876 8, 8, 8, 8, 7, 6, 5, 4
877 },
878 {
879 8, 8, 8, 8, 8, 7, 6, 5
880 },
881 {
882 8, 8, 8, 8, 8, 8, 7, 6
883 },
884 {
885 8, 8, 8, 8, 8, 8, 8, 7
886 },
887 {
888 8, 8, 8, 8, 8, 8, 8, 8
889 }
890 },
891 {
892 {
893 0, 0, 0, 0, 0, 0, 0, 0
894 },
895 {
896 15, 0, 0, 0, 0, 0, 0, 0
897 },
898 {
899 14, 15, 0, 0, 0, 0, 0, 0
900 },
901 {
902 13, 14, 15, 0, 0, 0, 0, 0
903 },
904 {
905 12, 13, 14, 15, 0, 0, 0, 0
906 },
907 {
908 11, 12, 13, 14, 15, 0, 0, 0
909 },
910 {
911 10, 11, 12, 13, 14, 15, 0, 0
912 },
913 {
914 9, 10, 11, 12, 13, 14, 15, 0
915 },
916 {
917 8, 9, 10, 11, 12, 13, 14, 15
918 },
919 {
920 8, 8, 9, 10, 11, 12, 13, 14
921 },
922 {
923 8, 8, 8, 9, 10, 11, 12, 13
924 },
925 {
926 8, 8, 8, 8, 9, 10, 11, 12
927 },
928 {
929 8, 8, 8, 8, 8, 9, 10, 11
930 },
931 {
932 8, 8, 8, 8, 8, 8, 9, 10
933 },
934 {
935 8, 8, 8, 8, 8, 8, 8, 9
936 },
937 {
938 8, 8, 8, 8, 8, 8, 8, 8
939 }
940 },
941 {
942 {
943 0, 0, 0, 0, 0, 0, 0, 0
944 },
945 {
946 0, 0, 0, 0, 0, 0, 0, 1
947 },
948 {
949 0, 0, 0, 0, 0, 0, 1, 2
950 },
951 {
952 0, 0, 0, 0, 0, 1, 2, 3
953 },
954 {
955 0, 0, 0, 0, 1, 2, 3, 4
956 },
957 {
958 0, 0, 0, 1, 2, 3, 4, 5
959 },
960 {
961 0, 0, 1, 2, 3, 4, 5, 6
962 },
963 {
964 0, 1, 2, 3, 4, 5, 6, 7
965 },
966 {
967 1, 2, 3, 4, 5, 6, 7, 8
968 },
969 {
970 2, 3, 4, 5, 6, 7, 8, 8
971 },
972 {
973 3, 4, 5, 6, 7, 8, 8, 8
974 },
975 {
976 4, 5, 6, 7, 8, 8, 8, 8
977 },
978 {
979 5, 6, 7, 8, 8, 8, 8, 8
980 },
981 {
982 6, 7, 8, 8, 8, 8, 8, 8
983 },
984 {
985 7, 8, 8, 8, 8, 8, 8, 8
986 },
987 {
988 8, 8, 8, 8, 8, 8, 8, 8
989 }
990 },
991 {
992 {
993 0, 0, 0, 0, 0, 0, 0, 0
994 },
995 {
996 0, 0, 0, 0, 0, 0, 0, 15
997 },
998 {
999 0, 0, 0, 0, 0, 0, 15, 14
1000 },
1001 {
1002 0, 0, 0, 0, 0, 15, 14, 13
1003 },
1004 {
1005 0, 0, 0, 0, 15, 14, 13, 12
1006 },
1007 {
1008 0, 0, 0, 15, 14, 13, 12, 11
1009 },
1010 {
1011 0, 0, 15, 14, 13, 12, 11, 10
1012 },
1013 {
1014 0, 15, 14, 13, 12, 11, 10, 9
1015 },
1016 {
1017 15, 14, 13, 12, 11, 10, 9, 8
1018 },
1019 {
1020 14, 13, 12, 11, 10, 9, 8, 8
1021 },
1022 {
1023 13, 12, 11, 10, 9, 8, 8, 8
1024 },
1025 {
1026 12, 11, 10, 9, 8, 8, 8, 8
1027 },
1028 {
1029 11, 10, 9, 8, 8, 8, 8, 8
1030 },
1031 {
1032 10, 9, 8, 8, 8, 8, 8, 8
1033 },
1034 {
1035 9, 8, 8, 8, 8, 8, 8, 8
1036 },
1037 {
1038 8, 8, 8, 8, 8, 8, 8, 8
1039 }
1040 }
1041 };
1042 */
1043
1044
1045
1046 /*
1047 for (int32_t blockrow=0; blockrow<30; ++i)
1048 {
1049 for (int32_t linerow=0; linerow<8; ++i)
1050 {
1051 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1052 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1053 {
1054 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1055 ++triangleline;
1056 }
1057 }
1058 }
1059 */
1060
1061 // the ULL suffixes are to prevent this warning:
1062 // warning: integer constant is too large for "int32_t" type
1063
1064 qword triangles[4][16][8]= //[direction][value][line]
1065 {
1066 {
1067 {
1068 0x0000000000000000ULL,
1069 0x0000000000000000ULL,
1070 0x0000000000000000ULL,
1071 0x0000000000000000ULL,
1072 0x0000000000000000ULL,
1073 0x0000000000000000ULL,
1074 0x0000000000000000ULL,
1075 0x0000000000000000ULL
1076 },
1077 {
1078 0xFD00000000000000ULL,
1079 0x0000000000000000ULL,
1080 0x0000000000000000ULL,
1081 0x0000000000000000ULL,
1082 0x0000000000000000ULL,
1083 0x0000000000000000ULL,
1084 0x0000000000000000ULL,
1085 0x0000000000000000ULL
1086 },
1087 {
1088 0xFDFD000000000000ULL,
1089 0xFD00000000000000ULL,
1090 0x0000000000000000ULL,
1091 0x0000000000000000ULL,
1092 0x0000000000000000ULL,
1093 0x0000000000000000ULL,
1094 0x0000000000000000ULL,
1095 0x0000000000000000ULL
1096 },
1097 {
1098 0xFDFDFD0000000000ULL,
1099 0xFDFD000000000000ULL,
1100 0xFD00000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL,
1105 0x0000000000000000ULL
1106 },
1107 {
1108 0xFDFDFDFD00000000ULL,
1109 0xFDFDFD0000000000ULL,
1110 0xFDFD000000000000ULL,
1111 0xFD00000000000000ULL,
1112 0x0000000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL,
1115 0x0000000000000000ULL
1116 },
1117 {
1118 0xFDFDFDFDFD000000ULL,
1119 0xFDFDFDFD00000000ULL,
1120 0xFDFDFD0000000000ULL,
1121 0xFDFD000000000000ULL,
1122 0xFD00000000000000ULL,
1123 0x0000000000000000ULL,
1124 0x0000000000000000ULL,
1125 0x0000000000000000ULL
1126 },
1127 {
1128 0xFDFDFDFDFDFD0000ULL,
1129 0xFDFDFDFDFD000000ULL,
1130 0xFDFDFDFD00000000ULL,
1131 0xFDFDFD0000000000ULL,
1132 0xFDFD000000000000ULL,
1133 0xFD00000000000000ULL,
1134 0x0000000000000000ULL,
1135 0x0000000000000000ULL
1136 },
1137 {
1138 0xFDFDFDFDFDFDFD00ULL,
1139 0xFDFDFDFDFDFD0000ULL,
1140 0xFDFDFDFDFD000000ULL,
1141 0xFDFDFDFD00000000ULL,
1142 0xFDFDFD0000000000ULL,
1143 0xFDFD000000000000ULL,
1144 0xFD00000000000000ULL,
1145 0x0000000000000000ULL
1146 },
1147 {
1148 0xFDFDFDFDFDFDFDFDULL,
1149 0xFDFDFDFDFDFDFD00ULL,
1150 0xFDFDFDFDFDFD0000ULL,
1151 0xFDFDFDFDFD000000ULL,
1152 0xFDFDFDFD00000000ULL,
1153 0xFDFDFD0000000000ULL,
1154 0xFDFD000000000000ULL,
1155 0xFD00000000000000ULL
1156 },
1157 {
1158 0xFDFDFDFDFDFDFDFDULL,
1159 0xFDFDFDFDFDFDFDFDULL,
1160 0xFDFDFDFDFDFDFD00ULL,
1161 0xFDFDFDFDFDFD0000ULL,
1162 0xFDFDFDFDFD000000ULL,
1163 0xFDFDFDFD00000000ULL,
1164 0xFDFDFD0000000000ULL,
1165 0xFDFD000000000000ULL
1166 },
1167 {
1168 0xFDFDFDFDFDFDFDFDULL,
1169 0xFDFDFDFDFDFDFDFDULL,
1170 0xFDFDFDFDFDFDFDFDULL,
1171 0xFDFDFDFDFDFDFD00ULL,
1172 0xFDFDFDFDFDFD0000ULL,
1173 0xFDFDFDFDFD000000ULL,
1174 0xFDFDFDFD00000000ULL,
1175 0xFDFDFD0000000000ULL
1176 },
1177 {
1178 0xFDFDFDFDFDFDFDFDULL,
1179 0xFDFDFDFDFDFDFDFDULL,
1180 0xFDFDFDFDFDFDFDFDULL,
1181 0xFDFDFDFDFDFDFDFDULL,
1182 0xFDFDFDFDFDFDFD00ULL,
1183 0xFDFDFDFDFDFD0000ULL,
1184 0xFDFDFDFDFD000000ULL,
1185 0xFDFDFDFD00000000ULL
1186 },
1187 {
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFDFDULL,
1191 0xFDFDFDFDFDFDFDFDULL,
1192 0xFDFDFDFDFDFDFDFDULL,
1193 0xFDFDFDFDFDFDFD00ULL,
1194 0xFDFDFDFDFDFD0000ULL,
1195 0xFDFDFDFDFD000000ULL
1196 },
1197 {
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFDFDULL,
1203 0xFDFDFDFDFDFDFDFDULL,
1204 0xFDFDFDFDFDFDFD00ULL,
1205 0xFDFDFDFDFDFD0000ULL
1206 },
1207 {
1208 0xFDFDFDFDFDFDFDFDULL,
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFDFDULL,
1213 0xFDFDFDFDFDFDFDFDULL,
1214 0xFDFDFDFDFDFDFDFDULL,
1215 0xFDFDFDFDFDFDFD00ULL
1216 },
1217 {
1218 0xFDFDFDFDFDFDFDFDULL,
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFDFDULL,
1224 0xFDFDFDFDFDFDFDFDULL,
1225 0xFDFDFDFDFDFDFDFDULL
1226 }
1227 },
1228 {
1229 {
1230 0x0000000000000000ULL,
1231 0x0000000000000000ULL,
1232 0x0000000000000000ULL,
1233 0x0000000000000000ULL,
1234 0x0000000000000000ULL,
1235 0x0000000000000000ULL,
1236 0x0000000000000000ULL,
1237 0x0000000000000000ULL
1238 },
1239 {
1240 0x00000000000000FDULL,
1241 0x0000000000000000ULL,
1242 0x0000000000000000ULL,
1243 0x0000000000000000ULL,
1244 0x0000000000000000ULL,
1245 0x0000000000000000ULL,
1246 0x0000000000000000ULL,
1247 0x0000000000000000ULL
1248 },
1249 {
1250 0x000000000000FDFDULL,
1251 0x00000000000000FDULL,
1252 0x0000000000000000ULL,
1253 0x0000000000000000ULL,
1254 0x0000000000000000ULL,
1255 0x0000000000000000ULL,
1256 0x0000000000000000ULL,
1257 0x0000000000000000ULL
1258 },
1259 {
1260 0x0000000000FDFDFDULL,
1261 0x000000000000FDFDULL,
1262 0x00000000000000FDULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL,
1267 0x0000000000000000ULL
1268 },
1269 {
1270 0x00000000FDFDFDFDULL,
1271 0x0000000000FDFDFDULL,
1272 0x000000000000FDFDULL,
1273 0x00000000000000FDULL,
1274 0x0000000000000000ULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL,
1277 0x0000000000000000ULL
1278 },
1279 {
1280 0x000000FDFDFDFDFDULL,
1281 0x00000000FDFDFDFDULL,
1282 0x0000000000FDFDFDULL,
1283 0x000000000000FDFDULL,
1284 0x00000000000000FDULL,
1285 0x0000000000000000ULL,
1286 0x0000000000000000ULL,
1287 0x0000000000000000ULL
1288 },
1289 {
1290 0x0000FDFDFDFDFDFDULL,
1291 0x000000FDFDFDFDFDULL,
1292 0x00000000FDFDFDFDULL,
1293 0x0000000000FDFDFDULL,
1294 0x000000000000FDFDULL,
1295 0x00000000000000FDULL,
1296 0x0000000000000000ULL,
1297 0x0000000000000000ULL
1298 },
1299 {
1300 0x00FDFDFDFDFDFDFDULL,
1301 0x0000FDFDFDFDFDFDULL,
1302 0x000000FDFDFDFDFDULL,
1303 0x00000000FDFDFDFDULL,
1304 0x0000000000FDFDFDULL,
1305 0x000000000000FDFDULL,
1306 0x00000000000000FDULL,
1307 0x0000000000000000ULL
1308 },
1309 {
1310 0xFDFDFDFDFDFDFDFDULL,
1311 0x00FDFDFDFDFDFDFDULL,
1312 0x0000FDFDFDFDFDFDULL,
1313 0x000000FDFDFDFDFDULL,
1314 0x00000000FDFDFDFDULL,
1315 0x0000000000FDFDFDULL,
1316 0x000000000000FDFDULL,
1317 0x00000000000000FDULL
1318 },
1319 {
1320 0xFDFDFDFDFDFDFDFDULL,
1321 0xFDFDFDFDFDFDFDFDULL,
1322 0x00FDFDFDFDFDFDFDULL,
1323 0x0000FDFDFDFDFDFDULL,
1324 0x000000FDFDFDFDFDULL,
1325 0x00000000FDFDFDFDULL,
1326 0x0000000000FDFDFDULL,
1327 0x000000000000FDFDULL
1328 },
1329 {
1330 0xFDFDFDFDFDFDFDFDULL,
1331 0xFDFDFDFDFDFDFDFDULL,
1332 0xFDFDFDFDFDFDFDFDULL,
1333 0x00FDFDFDFDFDFDFDULL,
1334 0x0000FDFDFDFDFDFDULL,
1335 0x000000FDFDFDFDFDULL,
1336 0x00000000FDFDFDFDULL,
1337 0x0000000000FDFDFDULL
1338 },
1339 {
1340 0xFDFDFDFDFDFDFDFDULL,
1341 0xFDFDFDFDFDFDFDFDULL,
1342 0xFDFDFDFDFDFDFDFDULL,
1343 0xFDFDFDFDFDFDFDFDULL,
1344 0x00FDFDFDFDFDFDFDULL,
1345 0x0000FDFDFDFDFDFDULL,
1346 0x000000FDFDFDFDFDULL,
1347 0x00000000FDFDFDFDULL
1348 },
1349 {
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0xFDFDFDFDFDFDFDFDULL,
1353 0xFDFDFDFDFDFDFDFDULL,
1354 0xFDFDFDFDFDFDFDFDULL,
1355 0x00FDFDFDFDFDFDFDULL,
1356 0x0000FDFDFDFDFDFDULL,
1357 0x000000FDFDFDFDFDULL
1358 },
1359 {
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0xFDFDFDFDFDFDFDFDULL,
1365 0xFDFDFDFDFDFDFDFDULL,
1366 0x00FDFDFDFDFDFDFDULL,
1367 0x0000FDFDFDFDFDFDULL
1368 },
1369 {
1370 0xFDFDFDFDFDFDFDFDULL,
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0xFDFDFDFDFDFDFDFDULL,
1375 0xFDFDFDFDFDFDFDFDULL,
1376 0xFDFDFDFDFDFDFDFDULL,
1377 0x00FDFDFDFDFDFDFDULL
1378 },
1379 {
1380 0xFDFDFDFDFDFDFDFDULL,
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0xFDFDFDFDFDFDFDFDULL,
1386 0xFDFDFDFDFDFDFDFDULL,
1387 0xFDFDFDFDFDFDFDFDULL
1388 }
1389 },
1390 {
1391 {
1392 0x0000000000000000ULL,
1393 0x0000000000000000ULL,
1394 0x0000000000000000ULL,
1395 0x0000000000000000ULL,
1396 0x0000000000000000ULL,
1397 0x0000000000000000ULL,
1398 0x0000000000000000ULL,
1399 0x0000000000000000ULL
1400 },
1401 {
1402 0x0000000000000000ULL,
1403 0x0000000000000000ULL,
1404 0x0000000000000000ULL,
1405 0x0000000000000000ULL,
1406 0x0000000000000000ULL,
1407 0x0000000000000000ULL,
1408 0x0000000000000000ULL,
1409 0xFD00000000000000ULL
1410 },
1411 {
1412 0x0000000000000000ULL,
1413 0x0000000000000000ULL,
1414 0x0000000000000000ULL,
1415 0x0000000000000000ULL,
1416 0x0000000000000000ULL,
1417 0x0000000000000000ULL,
1418 0xFD00000000000000ULL,
1419 0xFDFD000000000000ULL
1420 },
1421 {
1422 0x0000000000000000ULL,
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0xFD00000000000000ULL,
1428 0xFDFD000000000000ULL,
1429 0xFDFDFD0000000000ULL
1430 },
1431 {
1432 0x0000000000000000ULL,
1433 0x0000000000000000ULL,
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0xFD00000000000000ULL,
1437 0xFDFD000000000000ULL,
1438 0xFDFDFD0000000000ULL,
1439 0xFDFDFDFD00000000ULL
1440 },
1441 {
1442 0x0000000000000000ULL,
1443 0x0000000000000000ULL,
1444 0x0000000000000000ULL,
1445 0xFD00000000000000ULL,
1446 0xFDFD000000000000ULL,
1447 0xFDFDFD0000000000ULL,
1448 0xFDFDFDFD00000000ULL,
1449 0xFDFDFDFDFD000000ULL
1450 },
1451 {
1452 0x0000000000000000ULL,
1453 0x0000000000000000ULL,
1454 0xFD00000000000000ULL,
1455 0xFDFD000000000000ULL,
1456 0xFDFDFD0000000000ULL,
1457 0xFDFDFDFD00000000ULL,
1458 0xFDFDFDFDFD000000ULL,
1459 0xFDFDFDFDFDFD0000ULL
1460 },
1461 {
1462 0x0000000000000000ULL,
1463 0xFD00000000000000ULL,
1464 0xFDFD000000000000ULL,
1465 0xFDFDFD0000000000ULL,
1466 0xFDFDFDFD00000000ULL,
1467 0xFDFDFDFDFD000000ULL,
1468 0xFDFDFDFDFDFD0000ULL,
1469 0xFDFDFDFDFDFDFD00ULL
1470 },
1471 {
1472 0xFD00000000000000ULL,
1473 0xFDFD000000000000ULL,
1474 0xFDFDFD0000000000ULL,
1475 0xFDFDFDFD00000000ULL,
1476 0xFDFDFDFDFD000000ULL,
1477 0xFDFDFDFDFDFD0000ULL,
1478 0xFDFDFDFDFDFDFD00ULL,
1479 0xFDFDFDFDFDFDFDFDULL
1480 },
1481 {
1482 0xFDFD000000000000ULL,
1483 0xFDFDFD0000000000ULL,
1484 0xFDFDFDFD00000000ULL,
1485 0xFDFDFDFDFD000000ULL,
1486 0xFDFDFDFDFDFD0000ULL,
1487 0xFDFDFDFDFDFDFD00ULL,
1488 0xFDFDFDFDFDFDFDFDULL,
1489 0xFDFDFDFDFDFDFDFDULL
1490 },
1491 {
1492 0xFDFDFD0000000000ULL,
1493 0xFDFDFDFD00000000ULL,
1494 0xFDFDFDFDFD000000ULL,
1495 0xFDFDFDFDFDFD0000ULL,
1496 0xFDFDFDFDFDFDFD00ULL,
1497 0xFDFDFDFDFDFDFDFDULL,
1498 0xFDFDFDFDFDFDFDFDULL,
1499 0xFDFDFDFDFDFDFDFDULL
1500 },
1501 {
1502 0xFDFDFDFD00000000ULL,
1503 0xFDFDFDFDFD000000ULL,
1504 0xFDFDFDFDFDFD0000ULL,
1505 0xFDFDFDFDFDFDFD00ULL,
1506 0xFDFDFDFDFDFDFDFDULL,
1507 0xFDFDFDFDFDFDFDFDULL,
1508 0xFDFDFDFDFDFDFDFDULL,
1509 0xFDFDFDFDFDFDFDFDULL
1510 },
1511 {
1512 0xFDFDFDFDFD000000ULL,
1513 0xFDFDFDFDFDFD0000ULL,
1514 0xFDFDFDFDFDFDFD00ULL,
1515 0xFDFDFDFDFDFDFDFDULL,
1516 0xFDFDFDFDFDFDFDFDULL,
1517 0xFDFDFDFDFDFDFDFDULL,
1518 0xFDFDFDFDFDFDFDFDULL,
1519 0xFDFDFDFDFDFDFDFDULL
1520 },
1521 {
1522 0xFDFDFDFDFDFD0000ULL,
1523 0xFDFDFDFDFDFDFD00ULL,
1524 0xFDFDFDFDFDFDFDFDULL,
1525 0xFDFDFDFDFDFDFDFDULL,
1526 0xFDFDFDFDFDFDFDFDULL,
1527 0xFDFDFDFDFDFDFDFDULL,
1528 0xFDFDFDFDFDFDFDFDULL,
1529 0xFDFDFDFDFDFDFDFDULL
1530 },
1531 {
1532 0xFDFDFDFDFDFDFD00ULL,
1533 0xFDFDFDFDFDFDFDFDULL,
1534 0xFDFDFDFDFDFDFDFDULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL,
1539 0xFDFDFDFDFDFDFDFDULL
1540 },
1541 {
1542 0xFDFDFDFDFDFDFDFDULL,
1543 0xFDFDFDFDFDFDFDFDULL,
1544 0xFDFDFDFDFDFDFDFDULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL,
1549 0xFDFDFDFDFDFDFDFDULL
1550 }
1551 },
1552 {
1553 {
1554 0x0000000000000000ULL,
1555 0x0000000000000000ULL,
1556 0x0000000000000000ULL,
1557 0x0000000000000000ULL,
1558 0x0000000000000000ULL,
1559 0x0000000000000000ULL,
1560 0x0000000000000000ULL,
1561 0x0000000000000000ULL
1562 },
1563 {
1564 0x0000000000000000ULL,
1565 0x0000000000000000ULL,
1566 0x0000000000000000ULL,
1567 0x0000000000000000ULL,
1568 0x0000000000000000ULL,
1569 0x0000000000000000ULL,
1570 0x0000000000000000ULL,
1571 0x00000000000000FDULL
1572 },
1573 {
1574 0x0000000000000000ULL,
1575 0x0000000000000000ULL,
1576 0x0000000000000000ULL,
1577 0x0000000000000000ULL,
1578 0x0000000000000000ULL,
1579 0x0000000000000000ULL,
1580 0x00000000000000FDULL,
1581 0x000000000000FDFDULL
1582 },
1583 {
1584 0x0000000000000000ULL,
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x00000000000000FDULL,
1590 0x000000000000FDFDULL,
1591 0x0000000000FDFDFDULL
1592 },
1593 {
1594 0x0000000000000000ULL,
1595 0x0000000000000000ULL,
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x00000000000000FDULL,
1599 0x000000000000FDFDULL,
1600 0x0000000000FDFDFDULL,
1601 0x00000000FDFDFDFDULL
1602 },
1603 {
1604 0x0000000000000000ULL,
1605 0x0000000000000000ULL,
1606 0x0000000000000000ULL,
1607 0x00000000000000FDULL,
1608 0x000000000000FDFDULL,
1609 0x0000000000FDFDFDULL,
1610 0x00000000FDFDFDFDULL,
1611 0x000000FDFDFDFDFDULL
1612 },
1613 {
1614 0x0000000000000000ULL,
1615 0x0000000000000000ULL,
1616 0x00000000000000FDULL,
1617 0x000000000000FDFDULL,
1618 0x0000000000FDFDFDULL,
1619 0x00000000FDFDFDFDULL,
1620 0x000000FDFDFDFDFDULL,
1621 0x0000FDFDFDFDFDFDULL
1622 },
1623 {
1624 0x0000000000000000ULL,
1625 0x00000000000000FDULL,
1626 0x000000000000FDFDULL,
1627 0x0000000000FDFDFDULL,
1628 0x00000000FDFDFDFDULL,
1629 0x000000FDFDFDFDFDULL,
1630 0x0000FDFDFDFDFDFDULL,
1631 0x00FDFDFDFDFDFDFDULL
1632 },
1633 {
1634 0x00000000000000FDULL,
1635 0x000000000000FDFDULL,
1636 0x0000000000FDFDFDULL,
1637 0x00000000FDFDFDFDULL,
1638 0x000000FDFDFDFDFDULL,
1639 0x0000FDFDFDFDFDFDULL,
1640 0x00FDFDFDFDFDFDFDULL,
1641 0xFDFDFDFDFDFDFDFDULL
1642 },
1643 {
1644 0x000000000000FDFDULL,
1645 0x0000000000FDFDFDULL,
1646 0x00000000FDFDFDFDULL,
1647 0x000000FDFDFDFDFDULL,
1648 0x0000FDFDFDFDFDFDULL,
1649 0x00FDFDFDFDFDFDFDULL,
1650 0xFDFDFDFDFDFDFDFDULL,
1651 0xFDFDFDFDFDFDFDFDULL
1652 },
1653 {
1654 0x0000000000FDFDFDULL,
1655 0x00000000FDFDFDFDULL,
1656 0x000000FDFDFDFDFDULL,
1657 0x0000FDFDFDFDFDFDULL,
1658 0x00FDFDFDFDFDFDFDULL,
1659 0xFDFDFDFDFDFDFDFDULL,
1660 0xFDFDFDFDFDFDFDFDULL,
1661 0xFDFDFDFDFDFDFDFDULL
1662 },
1663 {
1664 0x00000000FDFDFDFDULL,
1665 0x000000FDFDFDFDFDULL,
1666 0x0000FDFDFDFDFDFDULL,
1667 0x00FDFDFDFDFDFDFDULL,
1668 0xFDFDFDFDFDFDFDFDULL,
1669 0xFDFDFDFDFDFDFDFDULL,
1670 0xFDFDFDFDFDFDFDFDULL,
1671 0xFDFDFDFDFDFDFDFDULL
1672 },
1673 {
1674 0x000000FDFDFDFDFDULL,
1675 0x0000FDFDFDFDFDFDULL,
1676 0x00FDFDFDFDFDFDFDULL,
1677 0xFDFDFDFDFDFDFDFDULL,
1678 0xFDFDFDFDFDFDFDFDULL,
1679 0xFDFDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL,
1681 0xFDFDFDFDFDFDFDFDULL
1682 },
1683 {
1684 0x0000FDFDFDFDFDFDULL,
1685 0x00FDFDFDFDFDFDFDULL,
1686 0xFDFDFDFDFDFDFDFDULL,
1687 0xFDFDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL,
1691 0xFDFDFDFDFDFDFDFDULL
1692 },
1693 {
1694 0x00FDFDFDFDFDFDFDULL,
1695 0xFDFDFDFDFDFDFDFDULL,
1696 0xFDFDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL,
1701 0xFDFDFDFDFDFDFDFDULL
1702 },
1703 {
1704 0xFDFDFDFDFDFDFDFDULL,
1705 0xFDFDFDFDFDFDFDFDULL,
1706 0xFDFDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL,
1711 0xFDFDFDFDFDFDFDFDULL
1712 }
1713 }
1714 };
1715
1716 int32_t black_opening_count=0;
1717 int32_t black_opening_x,black_opening_y;
1718 int32_t black_opening_shape;
1719
1720 1506 int32_t choose_opening_shape()
1721 {
1722 // First, count how many bits are set
1723 1506 int32_t numBits=0;
1724 int32_t bitCounter;
1725
1726
2/2
✓ Branch 0 taken 7530 times.
✓ Branch 1 taken 1506 times.
9036 for(int32_t i=0; i<bosMAX; i++)
1727 {
1728
2/2
✓ Branch 0 taken 5808 times.
✓ Branch 1 taken 1722 times.
7530 if(COOLSCROLL&(1<<i))
1729 1722 numBits++;
1730 7530 }
1731
1732 // Shouldn't happen...
1733
1/2
✓ Branch 0 taken 1506 times.
✗ Branch 1 not taken.
1506 if(numBits==0)
1734 return bosCIRCLE;
1735
1736 // Pick a bit
1737 1506 bitCounter=zc_rand()%numBits+1;
1738
1739
2/2
✓ Branch 0 taken 1989 times.
✓ Branch 1 taken 26 times.
2015 for(int32_t i=0; i<bosMAX; i++)
1740 {
1741 // If this bit is set, decrement the bit counter
1742
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 1636 times.
1989 if(COOLSCROLL&(1<<i))
1743 1636 bitCounter--;
1744
1745 // When the counter hits 0, return a value based on
1746 // which bit it stopped on.
1747 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1748
2/2
✓ Branch 0 taken 1480 times.
✓ Branch 1 taken 509 times.
1989 if(bitCounter==0)
1749 1480 return i;
1750 509 }
1751
1752 // Shouldn't be necessary, but the compiler might complain, at least
1753 26 return bosCIRCLE;
1754 1506 }
1755
1756 396 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1757 {
1758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1759
1760 396 int32_t w=256, h=224;
1761 396 int32_t blockrows=28, blockcolumns=32;
1762 396 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1763
1764
2/2
✓ Branch 0 taken 11088 times.
✓ Branch 1 taken 396 times.
11484 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1765 {
1766
2/2
✓ Branch 0 taken 354816 times.
✓ Branch 1 taken 11088 times.
365904 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1767 {
1768
2/2
✓ Branch 0 taken 147229 times.
✓ Branch 1 taken 207587 times.
354816 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1769 354816 }
1770 11088 }
1771
1772 396 black_opening_count = 66;
1773 396 black_opening_x = x;
1774 396 black_opening_y = y;
1775 396 lensclk = 0;
1776 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1777
1778
1779
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(black_opening_shape == bosFADEBLACK)
1780 {
1781 refreshTints();
1782 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1783 }
1784
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(wait)
1785 {
1786 FFCore.warpScriptCheck();
1787 for(int32_t i=0; i<66; i++)
1788 {
1789 draw_screen(tmpscr);
1790 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1791 advanceframe(true);
1792
1793 if(Quit)
1794 {
1795 break;
1796 }
1797 }
1798 }
1799 396 }
1800
1801 1110 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1802 {
1803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1110 times.
1110 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1804
1805 1110 int32_t w=256, h=224;
1806 1110 int32_t blockrows=28, blockcolumns=32;
1807 1110 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1808
1809
2/2
✓ Branch 0 taken 31080 times.
✓ Branch 1 taken 1110 times.
32190 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1810 {
1811
2/2
✓ Branch 0 taken 994560 times.
✓ Branch 1 taken 31080 times.
1025640 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1812 {
1813
2/2
✓ Branch 0 taken 506240 times.
✓ Branch 1 taken 488320 times.
994560 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1814 994560 }
1815 31080 }
1816
1817 1110 black_opening_count = -66;
1818 1110 black_opening_x = x;
1819 1110 black_opening_y = y;
1820 1110 lensclk = 0;
1821
1/2
✓ Branch 0 taken 1110 times.
✗ Branch 1 not taken.
1110 if(black_opening_shape == bosFADEBLACK)
1822 {
1823 refreshTints();
1824 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1825 }
1826
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 911 times.
1110 if(wait)
1827 {
1828 911 FFCore.warpScriptCheck();
1829
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 60126 times.
61037 for(int32_t i=0; i<66; i++)
1830 {
1831 60126 draw_screen(tmpscr);
1832 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1833 60126 advanceframe(true);
1834
1835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60126 times.
60126 if(Quit)
1836 {
1837 break;
1838 }
1839 60126 }
1840 911 }
1841 1110 }
1842
1843 99396 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1844 {
1845 99396 clear_to_color(tmp_scr,BLACK);
1846 99396 int32_t w=256, h=224;
1847
1848
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 594 times.
✓ Branch 3 taken 7656 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90288 times.
99396 switch(black_opening_shape)
1849 {
1850 case bosOVAL:
1851 {
1852 858 double new_w=(w/2)+abs(w/2-x);
1853 858 double new_h=(h/2)+abs(h/2-y);
1854 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1855 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1856 858 break;
1857 }
1858
1859 case bosTRIANGLE:
1860 {
1861 594 double new_w=(w/2)+abs(w/2-x);
1862 594 double new_h=(h/2)+abs(h/2-y);
1863 594 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1864 594 double P2= (PI/2);
1865 594 double P23=(2*PI/3);
1866 594 double P43=(4*PI/3);
1867 594 double Pa= (-4*PI*a/(3*max_a));
1868 594 double angle=P2+Pa;
1869 594 double a0=angle;
1870 594 double a2=angle+P23;
1871 594 double a4=angle+P43;
1872 1188 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1873 594 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1874 594 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1875 0);
1876 594 break;
1877 }
1878
1879 case bosSMAS:
1880 {
1881
2/2
✓ Branch 0 taken 4158 times.
✓ Branch 1 taken 3498 times.
7656 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1882
1883
2/2
✓ Branch 0 taken 214368 times.
✓ Branch 1 taken 7656 times.
222024 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1884 {
1885
2/2
✓ Branch 0 taken 1714944 times.
✓ Branch 1 taken 214368 times.
1929312 for(int32_t linerow=0; linerow<8; ++linerow)
1886 {
1887 1714944 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1888
1889
2/2
✓ Branch 0 taken 54878208 times.
✓ Branch 1 taken 1714944 times.
56593152 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1890 {
1891 164634624 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1892
6/6
✓ Branch 0 taken 39546648 times.
✓ Branch 1 taken 15331560 times.
✓ Branch 2 taken 35934032 times.
✓ Branch 3 taken 18944176 times.
✓ Branch 4 taken 20602472 times.
✓ Branch 5 taken 15331560 times.
54878208 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1893 54878208 [linerow];
1894 54878208 ++triangleline;
1895
1896
2/2
✓ Branch 0 taken 48018432 times.
✓ Branch 1 taken 6859776 times.
54878208 if(linerow==0)
1897 {
1898 6859776 }
1899 54878208 }
1900 1714944 }
1901 214368 }
1902
1903 7656 break;
1904 }
1905
1906 case bosFADEBLACK:
1907 {
1908 if(black_opening_count<0)
1909 {
1910 black_fade(zc_min(-black_opening_count,63));
1911 }
1912 else if(black_opening_count>0)
1913 {
1914 black_fade(63-zc_max(black_opening_count-3,0));
1915 }
1916 else black_fade(0);
1917 return; //no blitting from tmp_scr!
1918 }
1919
1920 90288 case bosCIRCLE:
1921 default:
1922 {
1923 90288 double new_w=(w/2)+abs(w/2-x);
1924 90288 double new_h=(h/2)+abs(h/2-y);
1925 90288 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1926 //circlefill(tmp_scr,x,y,a<<3,0);
1927 90288 circlefill(tmp_scr,x,y,r,0);
1928 90288 break;
1929 }
1930 }
1931
1932 99396 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1933 99396 }
1934
1935
1936 void black_fade(int32_t fadeamnt)
1937 {
1938 for(int32_t i=0; i < 0xEF; i++)
1939 {
1940 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1941 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1942 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1943 }
1944
1945 refreshpal = true;
1946 }
1947
1948 //----------------------------------------------------------------
1949
1950 44438973 bool item_disabled(int32_t item) //is this item disabled?
1951 {
1952
2/2
✓ Branch 0 taken 1796419 times.
✓ Branch 1 taken 42642554 times.
44438973 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1953 }
1954
1955 7617241 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1956 {
1957
2/2
✓ Branch 0 taken 135210 times.
✓ Branch 1 taken 7482031 times.
7617241 if(current_item(item_type, true) >=item)
1958 {
1959 135210 return true;
1960 }
1961
1962 7482031 return false;
1963 7617241 }
1964
1965 31051191 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1966 {
1967
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6052581 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3220277 times.
✓ Branch 6 taken 16169148 times.
✓ Branch 7 taken 5493498 times.
✓ Branch 8 taken 115687 times.
31051191 switch(item_type)
1968 {
1969 case itype_bomb:
1970 case itype_sbomb:
1971 {
1972 int32_t itemid = getItemID(itemsbuf, item_type, it);
1973
1974 if(itemid == -1)
1975 return false;
1976
1977 return (game->get_item(itemid));
1978 }
1979
1980 case itype_clock:
1981 {
1982 6052581 int32_t itemid = getItemID(itemsbuf, item_type, it);
1983
1984
2/4
✓ Branch 0 taken 6052581 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6052581 times.
✗ Branch 3 not taken.
6052581 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1985 return (game->get_item(itemid));
1986 6052581 return Hero.getClock()?1:0;
1987 }
1988
1989 case itype_key:
1990 return (game->get_keys()>0);
1991
1992 case itype_magiccontainer:
1993 return (game->get_maxmagic()>=game->get_mp_per_block());
1994
1995 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1996 {
1997
1/3
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3220277 switch(it)
1998 {
1999 case -2:
2000 {
2001 for(int32_t i=0; i<MAXLEVELS; i++)
2002 {
2003 if(game->lvlitems[i]&liTRIFORCE)
2004 {
2005 return true;
2006 }
2007 }
2008
2009 return false;
2010 }
2011
2012 case -1:
2013 return (game->lvlitems[dlevel]&liTRIFORCE);
2014
2015 default:
2016
2/4
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3220277 times.
3220277 if(it>=0&&it<MAXLEVELS)
2017 {
2018 3220277 return (game->lvlitems[it]&liTRIFORCE);
2019 }
2020
2021 break;
2022 }
2023
2024 return 0;
2025 }
2026
2027 case itype_map: //it: -2=any, -1=current level, other=that level
2028 {
2029
1/3
✓ Branch 0 taken 16169148 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
16169148 switch(it)
2030 {
2031 case -2:
2032 {
2033 for(int32_t i=0; i<MAXLEVELS; i++)
2034 {
2035 if(game->lvlitems[i]&liMAP)
2036 {
2037 return true;
2038 }
2039 }
2040
2041 return false;
2042 }
2043
2044 case -1:
2045 return (game->lvlitems[dlevel]&liMAP)!=0;
2046
2047 default:
2048
2/4
✓ Branch 0 taken 16169148 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16169148 times.
16169148 if(it>=0&&it<MAXLEVELS)
2049 {
2050 16169148 return (game->lvlitems[it]&liMAP)!=0;
2051 }
2052
2053 break;
2054 }
2055
2056 return 0;
2057 }
2058
2059 case itype_compass: //it: -2=any, -1=current level, other=that level
2060 {
2061
1/3
✓ Branch 0 taken 5493498 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
5493498 switch(it)
2062 {
2063 case -2:
2064 {
2065 for(int32_t i=0; i<MAXLEVELS; i++)
2066 {
2067 if(game->lvlitems[i]&liCOMPASS)
2068 {
2069 return true;
2070 }
2071 }
2072
2073 return false;
2074 }
2075
2076 case -1:
2077 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2078
2079 default:
2080
2/4
✓ Branch 0 taken 5493498 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5493498 times.
✗ Branch 3 not taken.
5493498 if(it>=0&&it<MAXLEVELS)
2081 {
2082 5493498 return (game->lvlitems[it]&liCOMPASS)!=0;
2083 }
2084
2085 break;
2086 }
2087 return 0;
2088 }
2089
2090 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2091 {
2092
1/3
✓ Branch 0 taken 115687 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
115687 switch(it)
2093 {
2094 case -2:
2095 {
2096 for(int32_t i=0; i<MAXLEVELS; i++)
2097 {
2098 if(game->lvlitems[i]&liBOSSKEY)
2099 {
2100 return true;
2101 }
2102 }
2103
2104 return false;
2105 }
2106
2107 case -1:
2108 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2109
2110 default:
2111
2/4
✓ Branch 0 taken 115687 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115687 times.
115687 if(it>=0&&it<MAXLEVELS)
2112 {
2113 115687 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2114 }
2115 break;
2116 }
2117 return 0;
2118 }
2119
2120 default:
2121 //it=(1<<(it-1));
2122 /*if (item_type>=itype_max)
2123 {
2124 enter_sys_pal();
2125 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2126 exit_sys_pal();
2127
2128 return false;
2129 }*/
2130 int32_t itemid = getItemID(itemsbuf, item_type, it);
2131
2132 if(itemid == -1)
2133 return false;
2134
2135 return game->get_item(itemid);
2136 }
2137 31051191 }
2138
2139
2140 100002173 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2141 {
2142
9/9
✓ Branch 0 taken 6052581 times.
✓ Branch 1 taken 51581525 times.
✓ Branch 2 taken 6052581 times.
✓ Branch 3 taken 6052581 times.
✓ Branch 4 taken 6052581 times.
✓ Branch 5 taken 6052581 times.
✓ Branch 6 taken 6052581 times.
✓ Branch 7 taken 6052581 times.
✓ Branch 8 taken 6052581 times.
100002173 switch(item_type)
2143 {
2144 case itype_clock:
2145 {
2146 6052581 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2147
2148
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6052581 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6052581 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2149 return itemsbuf[maxid].fam_type;
2150
2151 6052581 return has_item(itype_clock,1) ? 1 : 0;
2152 }
2153
2154 case itype_key:
2155 6052581 return game->get_keys();
2156
2157 case itype_lkey:
2158 6052581 return game->lvlkeys[get_dlevel()];
2159
2160 case itype_magiccontainer:
2161 6052581 return game->get_maxmagic()/game->get_mp_per_block();
2162
2163 case itype_triforcepiece:
2164 {
2165 6052581 int32_t count=0;
2166
2167
2/2
✓ Branch 0 taken 3098921472 times.
✓ Branch 1 taken 6052581 times.
3104974053 for(int32_t i=0; i<MAXLEVELS; i++)
2168 {
2169 3098921472 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2170 3098921472 }
2171
2172 6052581 return count;
2173 }
2174
2175 case itype_map:
2176 {
2177 6052581 int32_t count=0;
2178
2179
2/2
✓ Branch 0 taken 3098921472 times.
✓ Branch 1 taken 6052581 times.
3104974053 for(int32_t i=0; i<MAXLEVELS; i++)
2180 {
2181 3098921472 count+=(game->lvlitems[i]&liMAP)?1:0;
2182 3098921472 }
2183
2184 6052581 return count;
2185 }
2186
2187 case itype_compass:
2188 {
2189 6052581 int32_t count=0;
2190
2191
2/2
✓ Branch 0 taken 3098921472 times.
✓ Branch 1 taken 6052581 times.
3104974053 for(int32_t i=0; i<MAXLEVELS; i++)
2192 {
2193 3098921472 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2194 3098921472 }
2195
2196 6052581 return count;
2197 }
2198
2199 case itype_bosskey:
2200 {
2201 6052581 int32_t count=0;
2202
2203
2/2
✓ Branch 0 taken 3098921472 times.
✓ Branch 1 taken 6052581 times.
3104974053 for(int32_t i=0; i<MAXLEVELS; i++)
2204 {
2205 3098921472 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2206 3098921472 }
2207
2208 6052581 return count;
2209 }
2210
2211 default:
2212 51581525 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2213
2214
2/2
✓ Branch 0 taken 9872037 times.
✓ Branch 1 taken 41709488 times.
51581525 if(maxid == -1)
2215 41709488 return 0;
2216
2217 9872037 return itemsbuf[maxid].fam_type;
2218 }
2219 100002173 }
2220
2221 92384932 int32_t current_item(int32_t item_type) //item currently being used
2222 {
2223 92384932 return current_item(item_type, true);
2224 }
2225
2226 115 std::map<int32_t, int32_t> itemcache;
2227 115 std::map<int32_t, int32_t> itemcache_cost;
2228
2229 void removeFromItemCache(int32_t itemclass)
2230 {
2231 itemcache.erase(itemclass);
2232 itemcache_cost.erase(itemclass);
2233 }
2234
2235 5855854 void flushItemCache(bool justcost)
2236 {
2237 5855854 itemcache_cost.clear();
2238
2/2
✓ Branch 0 taken 5825932 times.
✓ Branch 1 taken 29922 times.
5855854 if(!justcost)
2239 29922 itemcache.clear();
2240
2/2
✓ Branch 0 taken 5825833 times.
✓ Branch 1 taken 99 times.
5825932 else if(replay_version_check(0,19))
2241 5825833 return;
2242
2243 //also fix the active subscreen if items were deleted -DD
2244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30021 times.
30021 if(game != NULL)
2245 {
2246 30021 verifyBothWeapons();
2247 30021 refresh_subscr_items();
2248 30021 }
2249 5855854 }
2250
2251 // This is used often, so it should be as direct as possible.
2252 3375775644 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check, bool check_bunny)
2253 {
2254 3375775644 bool use_cost_cache = replay_version_check(19);
2255
2/2
✓ Branch 0 taken 3300218964 times.
✓ Branch 1 taken 75556680 times.
3375775644 if(jinx_check)
2256 {
2257
4/4
✓ Branch 0 taken 47350331 times.
✓ Branch 1 taken 28206349 times.
✓ Branch 2 taken 8273869 times.
✓ Branch 3 taken 39076462 times.
75556680 if(!(HeroSwordClk() || HeroItemClk()))
2258 39076462 jinx_check = false; //not jinxed
2259 75556680 }
2260
2/2
✓ Branch 0 taken 1047446 times.
✓ Branch 1 taken 3374728198 times.
3375775644 if(!Hero.BunnyClock())
2261 3374728198 check_bunny = false; //not bunnied
2262
2/2
✓ Branch 0 taken 3346173741 times.
✓ Branch 1 taken 29601903 times.
3375775644 if(itemtype == itype_ring) checkmagic = true;
2263
4/4
✓ Branch 0 taken 3339295426 times.
✓ Branch 1 taken 36480218 times.
✓ Branch 2 taken 3307954430 times.
✓ Branch 3 taken 29252880 times.
6712982954 if (!jinx_check && !check_bunny
2264
3/4
✓ Branch 0 taken 3339295426 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3337207310 times.
✓ Branch 3 taken 2088116 times.
3339295426 && (use_cost_cache || itemtype != itype_ring))
2265 {
2266
4/4
✓ Branch 0 taken 185299029 times.
✓ Branch 1 taken 3124743517 times.
✓ Branch 2 taken 185112718 times.
✓ Branch 3 taken 186311 times.
3310042546 auto& cache = checkmagic && use_cost_cache ? itemcache_cost : itemcache;
2267 3310042546 auto res = cache.find(itemtype);
2268
2269
2/2
✓ Branch 0 taken 3294771709 times.
✓ Branch 1 taken 15270837 times.
3310042546 if(res != cache.end())
2270 3294771709 return res->second;
2271 15270837 }
2272
2273 81003935 int32_t result = -1;
2274 81003935 int32_t highestlevel = -1;
2275
2276
2/2
✓ Branch 0 taken 20737007360 times.
✓ Branch 1 taken 81003935 times.
20818011295 for(int32_t i=0; i<MAXITEMS; i++)
2277 {
2278
5/6
✓ Branch 0 taken 1520703583 times.
✓ Branch 1 taken 19216303777 times.
✓ Branch 2 taken 21878553 times.
✓ Branch 3 taken 1498825030 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21878553 times.
20737007360 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2279 {
2280
4/4
✓ Branch 0 taken 20037107 times.
✓ Branch 1 taken 1841446 times.
✓ Branch 2 taken 8694 times.
✓ Branch 3 taken 20028413 times.
21878553 if(checkmagic && itemtype != itype_magicring)
2281
2/2
✓ Branch 0 taken 20028243 times.
✓ Branch 1 taken 170 times.
20028413 if(!checkmagiccost(i))
2282 170 continue;
2283
6/6
✓ Branch 0 taken 18586122 times.
✓ Branch 1 taken 3292261 times.
✓ Branch 2 taken 243036 times.
✓ Branch 3 taken 3049225 times.
✓ Branch 4 taken 1846135 times.
✓ Branch 5 taken 1446126 times.
21878383 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1446126 times.
1446126 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2285 1446126 continue;
2286
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20432257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20432257 if(check_bunny && !checkbunny(i))
2287 continue;
2288
2289
2/2
✓ Branch 0 taken 280080 times.
✓ Branch 1 taken 20152177 times.
20432257 if(itemsbuf[i].fam_type >= highestlevel)
2290 {
2291 20152177 highestlevel = itemsbuf[i].fam_type;
2292 20152177 result=i;
2293 20152177 }
2294 20432257 }
2295 20735561064 }
2296
2297
3/4
✓ Branch 0 taken 44523717 times.
✓ Branch 1 taken 36480218 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44523717 times.
81003935 if(!(jinx_check || check_bunny)) //Can't cache jinx_check/check_bunny
2298 {
2299
2/2
✓ Branch 0 taken 2514 times.
✓ Branch 1 taken 44521203 times.
44523717 if (use_cost_cache)
2300 {
2301
2/2
✓ Branch 0 taken 894 times.
✓ Branch 1 taken 1620 times.
2514 if (!checkmagic)
2302 1620 itemcache[itemtype] = result;
2303
5/6
✓ Branch 0 taken 1620 times.
✓ Branch 1 taken 894 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1617 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
2514 if (checkmagic || result < 0 || checkmagiccost(result))
2304 2514 itemcache_cost[itemtype] = result;
2305 2514 }
2306 else
2307 {
2308 44521203 itemcache[itemtype] = result;
2309 }
2310 44523717 }
2311 81003935 return result;
2312 3375775644 }
2313
2314 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2315 3339739639 int32_t current_item_id(int32_t itype, bool checkmagic, bool jinx_check, bool check_bunny)
2316 {
2317
2/4
✓ Branch 0 taken 3339739639 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3339739639 times.
3339739639 if(itype < 0 || itype >= itype_max) return -1;
2318
1/2
✓ Branch 0 taken 3339739639 times.
✗ Branch 1 not taken.
3339739639 if(game->OverrideItems[itype] > -2)
2319 {
2320 auto ovid = game->OverrideItems[itype];
2321 if(ovid < 0 || ovid >= MAXITEMS)
2322 return -1;
2323 if(itemsbuf[ovid].family == itype)
2324 {
2325 if(itype == itype_magicring)
2326 checkmagic = false;
2327 else if(itype == itype_ring)
2328 checkmagic = true;
2329
2330 if(checkmagic && !checkmagiccost(ovid))
2331 return -1;
2332 if(jinx_check && !(itemsbuf[ovid].flags & ITEM_JINX_IMMUNE)
2333 && (usesSwordJinx(ovid) ? HeroSwordClk() : HeroItemClk()))
2334 return -1;
2335 return ovid;
2336 }
2337 }
2338 3339739639 auto ret = _c_item_id_internal(itype,checkmagic,jinx_check,check_bunny);
2339
2/2
✓ Branch 0 taken 39520675 times.
✓ Branch 1 taken 3300218964 times.
3339739639 if(!jinx_check) //If not already a jinx-immune-only check...
2340 {
2341 //And the player IS jinxed...
2342
4/4
✓ Branch 0 taken 3272355592 times.
✓ Branch 1 taken 27863372 times.
✓ Branch 2 taken 8172633 times.
✓ Branch 3 taken 3264182959 times.
3300218964 if(HeroSwordClk() || HeroItemClk())
2343 {
2344 //Then do a jinx-immune-only check here
2345 36036005 auto ret2 = _c_item_id_internal(itype,checkmagic,true,check_bunny);
2346 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2347 //Should NOT need a compat rule, as this should always return -1 in old quests.
2348
2/2
✓ Branch 0 taken 1261310 times.
✓ Branch 1 taken 34774695 times.
36036005 if(ret2 > -1) return ret2;
2349 34774695 }
2350 3298957654 }
2351 3338478329 return ret;
2352 3339739639 }
2353
2354 19333281 int32_t current_item_power(int32_t itemtype)
2355 {
2356 19333281 int32_t result = current_item_id(itemtype,true);
2357
2/2
✓ Branch 0 taken 14040573 times.
✓ Branch 1 taken 5292708 times.
19333281 return (result<0) ? 0 : itemsbuf[result].power;
2358 }
2359
2360 11 int32_t heart_container_id()
2361 {
2362
1/2
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
319 for(int32_t i=0; i<MAXITEMS; i++)
2363 {
2364
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 308 times.
319 if(itemsbuf[i].family == itype_heartcontainer)
2365 {
2366 11 return i;
2367 }
2368 308 }
2369 return -1;
2370 11 }
2371
2372 6052581 int32_t item_tile_mod()
2373 {
2374 6052581 int32_t tile=0;
2375
2376
2/2
✓ Branch 0 taken 1206356 times.
✓ Branch 1 taken 4846225 times.
6052581 if(game->get_bombs())
2377 {
2378 4846225 int32_t itemid = current_item_id(itype_bomb,false);
2379
3/4
✓ Branch 0 taken 4681056 times.
✓ Branch 1 taken 165169 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4681056 times.
4846225 if(itemid > -1 && checkbunny(itemid))
2380 4681056 tile+=itemsbuf[itemid].ltm;
2381 4846225 }
2382
2383
2/2
✓ Branch 0 taken 4539291 times.
✓ Branch 1 taken 1513290 times.
6052581 if(game->get_sbombs())
2384 {
2385 1513290 int32_t itemid = current_item_id(itype_sbomb,false);
2386
3/4
✓ Branch 0 taken 1511862 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1511862 times.
1513290 if(itemid > -1 && checkbunny(itemid))
2387 1511862 tile+=itemsbuf[itemid].ltm;
2388 1513290 }
2389
2390
2/2
✓ Branch 0 taken 5942881 times.
✓ Branch 1 taken 109700 times.
6052581 if(current_item(itype_clock))
2391 {
2392 109700 int32_t itemid =
2393
1/2
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
109700 get_qr(qr_HARDCODED_LITEM_LTMS)
2394 ? iClock
2395 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2396
2/4
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 109700 times.
109700 if(itemid > -1 && checkbunny(itemid))
2397 109700 tile+=itemsbuf[itemid].ltm;
2398 109700 }
2399
2400
2/2
✓ Branch 0 taken 4671840 times.
✓ Branch 1 taken 1380741 times.
6052581 if(current_item(itype_key))
2401 {
2402 1380741 int32_t itemid =
2403
1/2
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
1380741 get_qr(qr_HARDCODED_LITEM_LTMS)
2404 ? iKey
2405 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2406
2/4
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1380741 times.
1380741 if(itemid > -1 && checkbunny(itemid))
2407 1380741 tile+=itemsbuf[itemid].ltm;
2408 1380741 }
2409
2410
2/2
✓ Branch 0 taken 5785478 times.
✓ Branch 1 taken 267103 times.
6052581 if(current_item(itype_lkey))
2411 {
2412 267103 int32_t itemid =
2413
2/2
✓ Branch 0 taken 266193 times.
✓ Branch 1 taken 910 times.
267103 get_qr(qr_HARDCODED_LITEM_LTMS)
2414 ? iLevelKey
2415 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2416
2/4
✓ Branch 0 taken 267103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 267103 times.
267103 if(itemid > -1 && checkbunny(itemid))
2417 267103 tile+=itemsbuf[itemid].ltm;
2418 267103 }
2419
2420
2/2
✓ Branch 0 taken 1246671 times.
✓ Branch 1 taken 4805910 times.
6052581 if(current_item(itype_map))
2421 {
2422 4805910 int32_t itemid =
2423
1/2
✓ Branch 0 taken 4805910 times.
✗ Branch 1 not taken.
4805910 get_qr(qr_HARDCODED_LITEM_LTMS)
2424 ? iMap
2425 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2426
2/4
✓ Branch 0 taken 4805910 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4805910 times.
4805910 if(itemid > -1 && checkbunny(itemid))
2427 4805910 tile+=itemsbuf[itemid].ltm;
2428 4805910 }
2429
2430
2/2
✓ Branch 0 taken 1198789 times.
✓ Branch 1 taken 4853792 times.
6052581 if(current_item(itype_compass))
2431 {
2432 4853792 int32_t itemid =
2433
2/2
✓ Branch 0 taken 4772733 times.
✓ Branch 1 taken 81059 times.
4853792 get_qr(qr_HARDCODED_LITEM_LTMS)
2434 ? iCompass
2435 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2436
2/4
✓ Branch 0 taken 4853792 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4853792 times.
4853792 if(itemid > -1 && checkbunny(itemid))
2437 4853792 tile+=itemsbuf[itemid].ltm;
2438 4853792 }
2439
2440
2/2
✓ Branch 0 taken 3422036 times.
✓ Branch 1 taken 2630545 times.
6052581 if(current_item(itype_bosskey))
2441 {
2442 2630545 int32_t itemid =
2443
1/2
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
2630545 get_qr(qr_HARDCODED_LITEM_LTMS)
2444 ? iBossKey
2445 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2446
2/4
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2630545 times.
2630545 if(itemid > -1 && checkbunny(itemid))
2447 2630545 tile+=itemsbuf[itemid].ltm;
2448 2630545 }
2449
2450
2/2
✓ Branch 0 taken 2919391 times.
✓ Branch 1 taken 3133190 times.
6052581 if(current_item(itype_magiccontainer))
2451 {
2452 3133190 int32_t itemid =
2453
2/2
✓ Branch 0 taken 3040989 times.
✓ Branch 1 taken 92201 times.
3133190 get_qr(qr_HARDCODED_LITEM_LTMS)
2454 ? iMagicC
2455 92201 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2456
3/4
✓ Branch 0 taken 3133190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 3131320 times.
3133190 if(itemid > -1 && checkbunny(itemid))
2457 3131320 tile+=itemsbuf[itemid].ltm;
2458 3133190 }
2459
2460
2/2
✓ Branch 0 taken 1591947 times.
✓ Branch 1 taken 4460634 times.
6052581 if(current_item(itype_triforcepiece))
2461 {
2462 4460634 int32_t itemid =
2463
1/2
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
4460634 get_qr(qr_HARDCODED_LITEM_LTMS)
2464 ? iTriforce
2465 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2466
2/4
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4460634 times.
4460634 if(itemid > -1 && checkbunny(itemid))
2467 4460634 tile+=itemsbuf[itemid].ltm;
2468 4460634 }
2469
2470
2/2
✓ Branch 0 taken 6052581 times.
✓ Branch 1 taken 3098921472 times.
3104974053 for(int32_t i=0; i<itype_max; i++)
2471 {
2472
2/2
✓ Branch 0 taken 3042451456 times.
✓ Branch 1 taken 56470016 times.
3098921472 if(!get_qr(qr_HARDCODED_LITEM_LTMS))
2473 {
2474
2/2
✓ Branch 0 taken 1102930 times.
✓ Branch 1 taken 55367086 times.
56470016 switch(i)
2475 {
2476 case itype_bomb:
2477 case itype_sbomb:
2478 case itype_clock:
2479 case itype_key:
2480 case itype_lkey:
2481 case itype_map:
2482 case itype_compass:
2483 case itype_bosskey:
2484 case itype_magiccontainer:
2485 case itype_triforcepiece:
2486 1102930 continue; //already handled
2487 }
2488 55367086 }
2489 3097818542 int32_t itemid = current_item_id(i,false);
2490
2/2
✓ Branch 0 taken 3091765961 times.
✓ Branch 1 taken 6052581 times.
3097818542 if(i == itype_shield)
2491 6052581 itemid = getCurrentShield(false);
2492
2493
4/4
✓ Branch 0 taken 80828448 times.
✓ Branch 1 taken 3016990094 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 80727467 times.
3097818542 if(itemid < 0 || !checkbunny(itemid))
2494 3017091075 continue;
2495
2496 80727467 itemdata const& itm = itemsbuf[itemid];
2497
2498
2/2
✓ Branch 0 taken 75312220 times.
✓ Branch 1 taken 5415247 times.
80727467 switch(itm.family)
2499 {
2500 case itype_shield:
2501
1/2
✓ Branch 0 taken 5415247 times.
✗ Branch 1 not taken.
5415247 if(itm.flags & ITEM_FLAG9) //active shield
2502 {
2503 if(!usingActiveShield(itemid))
2504 {
2505 tile+=itm.misc6; //'Inactive PTM'
2506 continue;
2507 }
2508 }
2509 5415247 break;
2510 }
2511
2512 80727467 tile+=itm.ltm;
2513 80727467 }
2514
2515 6052581 return tile;
2516 }
2517
2518 6052581 int32_t bunny_tile_mod()
2519 {
2520
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 6050711 times.
6052581 if(Hero.BunnyClock())
2521 {
2522 1870 return game->get_bunny_ltm();
2523 }
2524 6050711 return 0;
2525 6052581 }
2526
2527 // Hints are drawn on a separate layer to combo reveals.
2528 16332 void draw_lens_under(BITMAP *dest, bool layer)
2529 {
2530 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2531 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2532 //Lens flag 3: Don't show armos/chest/dive items
2533 //Lens flag 4: Show Raft Paths
2534 //Lens flag 5: Show Invisible Enemies
2535
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2536
2537 16332 int32_t strike_hint_table[11]=
2538 {
2539 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2540 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2541 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2542 };
2543
2544 // int32_t page = tmpscr->cpage;
2545 {
2546 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2547 // int32_t temptimer=0;
2548 16332 int32_t tempitem, tempweapon=0;
2549 16332 strike_hint=strike_hint_table[strike_hint_counter];
2550
2551
2/2
✓ Branch 0 taken 15842 times.
✓ Branch 1 taken 490 times.
16332 if(strike_hint_timer>32)
2552 {
2553 490 strike_hint_timer=0;
2554 490 strike_hint_counter=((strike_hint_counter+1)%11);
2555 490 }
2556
2557 16332 ++strike_hint_timer;
2558
2559
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2560 {
2561 2874432 int32_t x = (i & 15) << 4;
2562 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2563 2874432 int32_t tempitemx=-16, tempitemy=-16;
2564 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2565
2566
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2567 {
2568 5748864 int32_t checkflag=0;
2569
2570
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2571 {
2572 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2573 2874432 }
2574 else
2575 {
2576 2874432 checkflag=tmpscr->sflag[i];
2577 }
2578
2579
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2580 {
2581
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2582 {
2583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2584 906 }
2585 else
2586 {
2587 192 checkflag = strike_hint;
2588 }
2589 1098 }
2590
2591
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2592 {
2593 case 0:
2594 case mfZELDA:
2595 case mfPUSHED:
2596 case mfENEMY0:
2597 case mfENEMY1:
2598 case mfENEMY2:
2599 case mfENEMY3:
2600 case mfENEMY4:
2601 case mfENEMY5:
2602 case mfENEMY6:
2603 case mfENEMY7:
2604 case mfENEMY8:
2605 case mfENEMY9:
2606 case mfSINGLE:
2607 case mfSINGLE16:
2608 case mfNOENEMY:
2609 case mfTRAP_H:
2610 case mfTRAP_V:
2611 case mfTRAP_4:
2612 case mfTRAP_LR:
2613 case mfTRAP_UD:
2614 case mfNOGROUNDENEMY:
2615 case mfNOBLOCKS:
2616 case mfSCRIPT1:
2617 case mfSCRIPT2:
2618 case mfSCRIPT3:
2619 case mfSCRIPT4:
2620 case mfSCRIPT5:
2621 case mfSCRIPT6:
2622 case mfSCRIPT7:
2623 case mfSCRIPT8:
2624 case mfSCRIPT9:
2625 case mfSCRIPT10:
2626 case mfSCRIPT11:
2627 case mfSCRIPT12:
2628 case mfSCRIPT13:
2629 case mfSCRIPT14:
2630 case mfSCRIPT15:
2631 case mfSCRIPT16:
2632 case mfSCRIPT17:
2633 case mfSCRIPT18:
2634 case mfSCRIPT19:
2635 case mfSCRIPT20:
2636 case mfPITHOLE:
2637 case mfPITFALLFLOOR:
2638 case mfLAVA:
2639 case mfICE:
2640 case mfICEDAMAGE:
2641 case mfDAMAGE1:
2642 case mfDAMAGE2:
2643 case mfDAMAGE4:
2644 case mfDAMAGE8:
2645 case mfDAMAGE16:
2646 case mfDAMAGE32:
2647 case mfFREEZEALL:
2648 case mfFREZEALLANSFFCS:
2649 case mfFREEZEFFCSOLY:
2650 case mfSCRITPTW1TRIG:
2651 case mfSCRITPTW2TRIG:
2652 case mfSCRITPTW3TRIG:
2653 case mfSCRITPTW4TRIG:
2654 case mfSCRITPTW5TRIG:
2655 case mfSCRITPTW6TRIG:
2656 case mfSCRITPTW7TRIG:
2657 case mfSCRITPTW8TRIG:
2658 case mfSCRITPTW9TRIG:
2659 case mfSCRITPTW10TRIG:
2660 case mfTROWEL:
2661 case mfTROWELNEXT:
2662 case mfTROWELSPECIALITEM:
2663 case mfSLASHPOT:
2664 case mfLIFTPOT:
2665 case mfLIFTORSLASH:
2666 case mfLIFTROCK:
2667 case mfLIFTROCKHEAVY:
2668 case mfDROPITEM:
2669 case mfSPECIALITEM:
2670 case mfDROPKEY:
2671 case mfDROPLKEY:
2672 case mfDROPCOMPASS:
2673 case mfDROPMAP:
2674 case mfDROPBOSSKEY:
2675 case mfSPAWNNPC:
2676 case mfSWITCHHOOK:
2677 case mfSIDEVIEWLADDER:
2678 case mfSIDEVIEWPLATFORM:
2679 case mfNOENEMYSPAWN:
2680 case mfENEMYALL:
2681 case mfNOMIRROR:
2682 case mfUNSAFEGROUND:
2683 case mf168:
2684 case mf169:
2685 case mf170:
2686 case mf171:
2687 case mf172:
2688 case mf173:
2689 case mf174:
2690 case mf175:
2691 case mf176:
2692 case mf177:
2693 case mf178:
2694 case mf179:
2695 case mf180:
2696 case mf181:
2697 case mf182:
2698 case mf183:
2699 case mf184:
2700 case mf185:
2701 case mf186:
2702 case mf187:
2703 case mf188:
2704 case mf189:
2705 case mf190:
2706 case mf191:
2707 case mf192:
2708 case mf193:
2709 case mf194:
2710 case mf195:
2711 case mf196:
2712 case mf197:
2713 case mf198:
2714 case mf199:
2715 case mf200:
2716 case mf201:
2717 case mf202:
2718 case mf203:
2719 case mf204:
2720 case mf205:
2721 case mf206:
2722 case mf207:
2723 case mf208:
2724 case mf209:
2725 case mf210:
2726 case mf211:
2727 case mf212:
2728 case mf213:
2729 case mf214:
2730 case mf215:
2731 case mf216:
2732 case mf217:
2733 case mf218:
2734 case mf219:
2735 case mf220:
2736 case mf221:
2737 case mf222:
2738 case mf223:
2739 case mf224:
2740 case mf225:
2741 case mf226:
2742 case mf227:
2743 case mf228:
2744 case mf229:
2745 case mf230:
2746 case mf231:
2747 case mf232:
2748 case mf233:
2749 case mf234:
2750 case mf235:
2751 case mf236:
2752 case mf237:
2753 case mf238:
2754 case mf239:
2755 case mf240:
2756 case mf241:
2757 case mf242:
2758 case mf243:
2759 case mf244:
2760 case mf245:
2761 case mf246:
2762 case mf247:
2763 case mf248:
2764 case mf249:
2765 case mf250:
2766 case mf251:
2767 case mf252:
2768 case mf253:
2769 case mf254:
2770 case mfEXTENDED:
2771 5706470 break;
2772
2773 case mfPUSHUD:
2774 case mfPUSHLR:
2775 case mfPUSH4:
2776 case mfPUSHU:
2777 case mfPUSHD:
2778 case mfPUSHL:
2779 case mfPUSHR:
2780 case mfPUSHUDNS:
2781 case mfPUSHLRNS:
2782 case mfPUSH4NS:
2783 case mfPUSHUNS:
2784 case mfPUSHDNS:
2785 case mfPUSHLNS:
2786 case mfPUSHRNS:
2787 case mfPUSHUDINS:
2788 case mfPUSHLRINS:
2789 case mfPUSH4INS:
2790 case mfPUSHUINS:
2791 case mfPUSHDINS:
2792 case mfPUSHLINS:
2793 case mfPUSHRINS:
2794
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2795
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2796 {
2797 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2798 }
2799
2800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2801
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2802 {
2803
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2804 {
2805
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2806 {
2807 case cPUSH_HEAVY:
2808 case cPUSH_HW:
2809 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2810 72 tempitemx=x, tempitemy=y;
2811
2812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2813 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2814
2815 72 break;
2816
2817 case cPUSH_HEAVY2:
2818 case cPUSH_HW2:
2819 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2820 63 tempitemx=x, tempitemy=y;
2821
2822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2823 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2824
2825 63 break;
2826 }
2827 1032 }
2828 2438 }
2829
2830 3148 break;
2831
2832 case mfWHISTLE:
2833
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2834 {
2835 tempitem=getItemID(itemsbuf,itype_whistle,1);
2836
2837 if(tempitem<0) break;
2838
2839 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2840 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2841 {
2842 tempitemx=x;
2843 tempitemy=y;
2844 }
2845
2846 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2847 }
2848
2849 2418 break;
2850
2851 //Why is this here?
2852 case mfFAIRY:
2853 case mfMAGICFAIRY:
2854 case mfALLFAIRY:
2855 if(hints)
2856 {
2857 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2858
2859 if(tempitem < 0) break;
2860
2861 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2862 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2863 {
2864 tempitemx=x;
2865 tempitemy=y;
2866 }
2867
2868 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2869 }
2870
2871 break;
2872
2873 case mfANYFIRE:
2874
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2875 {
2876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2877 252 }
2878 else
2879 {
2880 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2881
2882
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2883
2884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2885
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2886 {
2887 189 tempitemx=x;
2888 189 tempitemy=y;
2889 189 }
2890
2891 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2892 }
2893
2894 504 break;
2895
2896 case mfSTRONGFIRE:
2897 if(!hints)
2898 {
2899 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2900 }
2901 else
2902 {
2903 tempitem=getItemID(itemsbuf,itype_candle,2);
2904
2905 if(tempitem<0) break;
2906
2907 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2908 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2909 {
2910 tempitemx=x;
2911 tempitemy=y;
2912 }
2913
2914 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2915 }
2916
2917 break;
2918
2919 case mfMAGICFIRE:
2920 if(!hints)
2921 {
2922 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2923 }
2924 else
2925 {
2926 tempitem=getItemID(itemsbuf,itype_wand,1);
2927
2928 if(tempitem<0) break;
2929
2930 tempweapon=wFire;
2931
2932 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2933 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2934 {
2935 tempitemx=x;
2936 tempitemy=y;
2937 }
2938 else
2939 {
2940 tempweaponx=x;
2941 tempweapony=y;
2942 }
2943
2944 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2945 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2946 }
2947
2948 break;
2949
2950 case mfDIVINEFIRE:
2951 if(!hints)
2952 {
2953 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2954 }
2955 else
2956 {
2957 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2958
2959 if(tempitem<0) break;
2960
2961 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2962 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2963 {
2964 tempitemx=x;
2965 tempitemy=y;
2966 }
2967
2968 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2969 }
2970
2971 break;
2972
2973 case mfARROW:
2974
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2975 {
2976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2977 732 }
2978 else
2979 {
2980 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2981
2982
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2983
2984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2985
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2986 {
2987 61 tempitemx=x;
2988 61 tempitemy=y;
2989 61 }
2990
2991 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2992 }
2993
2994 814 break;
2995
2996 case mfSARROW:
2997 if(!hints)
2998 {
2999 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
3000 }
3001 else
3002 {
3003 tempitem=getItemID(itemsbuf,itype_arrow,2);
3004
3005 if(tempitem<0) break;
3006
3007 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3008 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3009 {
3010 tempitemx=x;
3011 tempitemy=y;
3012 }
3013
3014 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3015 }
3016
3017 break;
3018
3019 case mfGARROW:
3020 if(!hints)
3021 {
3022 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3023 }
3024 else
3025 {
3026 tempitem=getItemID(itemsbuf,itype_arrow,3);
3027
3028 if(tempitem<0) break;
3029
3030 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3031 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3032 {
3033 tempitemx=x;
3034 tempitemy=y;
3035 }
3036
3037 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3038 }
3039
3040 break;
3041
3042 case mfBOMB:
3043
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3044 {
3045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3046 16 }
3047 else
3048 {
3049 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3050 17 tempweapon = wLitBomb;
3051
3052 //if (tempitem<0) break;
3053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3054
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3055 {
3056 12 tempweaponx=x;
3057 12 tempweapony=y;
3058 12 }
3059
3060 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3061 }
3062
3063 33 break;
3064
3065 case mfSBOMB:
3066
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3067 {
3068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3069 48 }
3070 else
3071 {
3072 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3073 //if (tempitem<0) break;
3074 48 tempweapon = wLitSBomb;
3075
3076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3077
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3078 {
3079 36 tempweaponx=x;
3080 36 tempweapony=y;
3081 36 }
3082
3083 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3084 }
3085
3086 96 break;
3087
3088 case mfARMOS_SECRET:
3089
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3090 {
3091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3092 12 }
3093 24 break;
3094
3095 case mfBRANG:
3096
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3097 {
3098 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3099 }
3100 else
3101 {
3102 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3103
3104
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3105
3106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3107
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3108 {
3109 4 tempitemx=x;
3110 4 tempitemy=y;
3111 4 }
3112
3113 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3114 }
3115
3116 5 break;
3117
3118 case mfMBRANG:
3119 if(!hints)
3120 {
3121 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3122 }
3123 else
3124 {
3125 tempitem=getItemID(itemsbuf,itype_brang,2);
3126
3127 if(tempitem<0) break;
3128
3129 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3130 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3131 {
3132 tempitemx=x;
3133 tempitemy=y;
3134 }
3135
3136 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3137 }
3138
3139 break;
3140
3141 case mfFBRANG:
3142 if(!hints)
3143 {
3144 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3145 }
3146 else
3147 {
3148 tempitem=getItemID(itemsbuf,itype_brang,3);
3149
3150 if(tempitem<0) break;
3151
3152 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3153 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3154 {
3155 tempitemx=x;
3156 tempitemy=y;
3157 }
3158
3159 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3160 }
3161
3162 break;
3163
3164 case mfWANDMAGIC:
3165 if(!hints)
3166 {
3167 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3168 }
3169 else
3170 {
3171 tempitem=getItemID(itemsbuf,itype_wand,1);
3172
3173 if(tempitem<0) break;
3174
3175 tempweapon=itemsbuf[tempitem].wpn3;
3176
3177 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3178 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3179 {
3180 tempitemx=x;
3181 tempitemy=y;
3182 }
3183 else
3184 {
3185 tempweaponx=x;
3186 tempweapony=y;
3187 --lens_hint_weapon[wMagic][4];
3188
3189 if(lens_hint_weapon[wMagic][4]<-8)
3190 {
3191 lens_hint_weapon[wMagic][4]=8;
3192 }
3193 }
3194
3195 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3196 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3197 }
3198
3199 break;
3200
3201 case mfREFMAGIC:
3202
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3203 {
3204 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3205 }
3206 else
3207 {
3208 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3209
3210
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3211
3212 16 tempweapon=ewMagic;
3213
3214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3215
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3216 {
3217 13 tempitemx=x;
3218 13 tempitemy=y;
3219 13 }
3220 else
3221 {
3222 3 tempweaponx=x;
3223 3 tempweapony=y;
3224
3225
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3226 {
3227 1 --lens_hint_weapon[ewMagic][4];
3228 1 }
3229 else
3230 {
3231 2 ++lens_hint_weapon[ewMagic][4];
3232 }
3233
3234
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3235 {
3236 lens_hint_weapon[ewMagic][2]=up;
3237 }
3238
3239
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3240 {
3241 2 lens_hint_weapon[ewMagic][2]=down;
3242 2 }
3243 }
3244
3245 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3246 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3247 }
3248
3249 16 break;
3250
3251 case mfREFFIREBALL:
3252
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3253 {
3254 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3255 }
3256 else
3257 {
3258 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3259
3260
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3261
3262 16 tempweapon=ewFireball;
3263
3264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3265
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3266 {
3267 12 tempitemx=x;
3268 12 tempitemy=y;
3269 12 tempweaponx=x;
3270 12 tempweapony=y;
3271 12 ++lens_hint_weapon[ewFireball][3];
3272
3273
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3274 {
3275 1 lens_hint_weapon[ewFireball][3]=-8;
3276 1 lens_hint_weapon[ewFireball][4]=8;
3277 1 }
3278
3279
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3280 {
3281 8 ++lens_hint_weapon[ewFireball][4];
3282 8 }
3283 else
3284 {
3285 4 --lens_hint_weapon[ewFireball][4];
3286 }
3287 12 }
3288
3289 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3290 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3291 }
3292
3293 16 break;
3294
3295 case mfSWORD:
3296
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3297 {
3298 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3299 }
3300 else
3301 {
3302 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3303
3304
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3305
3306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3307
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3308 {
3309 5 tempitemx=x;
3310 5 tempitemy=y;
3311 5 }
3312
3313 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3314 }
3315
3316 7 break;
3317
3318 case mfWSWORD:
3319 if(!hints)
3320 {
3321 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3322 }
3323 else
3324 {
3325 tempitem=getItemID(itemsbuf,itype_sword,2);
3326
3327 if(tempitem<0) break;
3328
3329 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3330 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3331 {
3332 tempitemx=x;
3333 tempitemy=y;
3334 }
3335
3336 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3337 }
3338
3339 break;
3340
3341 case mfMSWORD:
3342 if(!hints)
3343 {
3344 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3345 }
3346 else
3347 {
3348 tempitem=getItemID(itemsbuf,itype_sword,3);
3349
3350 if(tempitem<0) break;
3351
3352 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3353 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3354 {
3355 tempitemx=x;
3356 tempitemy=y;
3357 }
3358
3359 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3360 }
3361
3362 break;
3363
3364 case mfXSWORD:
3365 if(!hints)
3366 {
3367 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3368 }
3369 else
3370 {
3371 tempitem=getItemID(itemsbuf,itype_sword,4);
3372
3373 if(tempitem<0) break;
3374
3375 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3376 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3377 {
3378 tempitemx=x;
3379 tempitemy=y;
3380 }
3381
3382 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3383 }
3384
3385 break;
3386
3387 case mfSWORDBEAM:
3388
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3389 {
3390 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3391 }
3392 else
3393 {
3394 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3395
3396
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3397
3398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3399
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3400 {
3401 11 tempitemx=x;
3402 11 tempitemy=y;
3403 11 }
3404
3405 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3406 }
3407
3408 16 break;
3409
3410 case mfWSWORDBEAM:
3411 if(!hints)
3412 {
3413 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3414 }
3415 else
3416 {
3417 tempitem=getItemID(itemsbuf,itype_sword,2);
3418
3419 if(tempitem<0) break;
3420
3421 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3422 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3423 {
3424 tempitemx=x;
3425 tempitemy=y;
3426 }
3427
3428 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3429 }
3430
3431 break;
3432
3433 case mfMSWORDBEAM:
3434 if(!hints)
3435 {
3436 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3437 }
3438 else
3439 {
3440 tempitem=getItemID(itemsbuf,itype_sword,3);
3441
3442 if(tempitem<0) break;
3443
3444 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3445 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3446 {
3447 tempitemx=x;
3448 tempitemy=y;
3449 }
3450
3451 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3452 }
3453
3454 break;
3455
3456 case mfXSWORDBEAM:
3457 if(!hints)
3458 {
3459 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3460 }
3461 else
3462 {
3463 tempitem=getItemID(itemsbuf,itype_sword,4);
3464
3465 if(tempitem<0) break;
3466
3467 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3468 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3469 {
3470 tempitemx=x;
3471 tempitemy=y;
3472 }
3473
3474 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3475 }
3476
3477 break;
3478
3479 case mfHOOKSHOT:
3480
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3481 {
3482 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3483 }
3484 else
3485 {
3486 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3487
3488
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3489
3490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3491
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3492 {
3493 12 tempitemx=x;
3494 12 tempitemy=y;
3495 12 }
3496
3497 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3498 }
3499
3500 17 break;
3501
3502 case mfWAND:
3503
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3504 {
3505 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3506 }
3507 else
3508 {
3509 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3510
3511
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3512
3513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3514
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3515 {
3516 28 tempitemx=x;
3517 28 tempitemy=y;
3518 28 }
3519
3520 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3521 }
3522
3523 35 break;
3524
3525 case mfHAMMER:
3526
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3527 {
3528 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3529 }
3530 else
3531 {
3532 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3533
3534
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3535
3536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3537
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3538 {
3539 13 tempitemx=x;
3540 13 tempitemy=y;
3541 13 }
3542
3543 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3544 }
3545
3546 17 break;
3547
3548 case mfARMOS_ITEM:
3549 case mfDIVE_ITEM:
3550
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3551 {
3552 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3553 2064 }
3554 2064 break;
3555
3556 case 16:
3557 case 17:
3558 case 18:
3559 case 19:
3560 case 20:
3561 case 21:
3562 case 22:
3563 case 23:
3564 case 24:
3565 case 25:
3566 case 26:
3567 case 27:
3568 case 28:
3569 case 29:
3570 case 30:
3571 case 31:
3572
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3574 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3575
3576 3618 break;
3577 case mfSECRETSNEXT:
3578 if(!hints)
3579 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3580 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3581
3582 break;
3583
3584 case mfSTRIKE:
3585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3586 {
3587 906 goto special;
3588 }
3589 else
3590 {
3591 break;
3592 }
3593
3594 28640 default: goto special;
3595
3596 special:
3597
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3598 {
3599
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3600 {
3601 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3602 4913 }
3603 6549 }
3604
3605 29546 break;
3606 }
3607 5748864 }
3608 2874432 }
3609
3610
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3611 {
3612
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3613 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3614
3615
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3616 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3617
3618
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3619 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3620
3621
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3622 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3623
3624
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3625 {
3626 43 showbombeddoor(dest, 0);
3627 43 }
3628
3629
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3630 {
3631 39 showbombeddoor(dest, 1);
3632 39 }
3633
3634
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3635 {
3636 showbombeddoor(dest, 2);
3637 }
3638
3639
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3640 {
3641 37 showbombeddoor(dest, 3);
3642 37 }
3643 8166 }
3644
3645
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3646 {
3647
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3648 {
3649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3650 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3651 1123 }
3652 else
3653 {
3654
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3655 {
3656 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3657 48 int32_t tempitemx=-16;
3658 48 int32_t tempitemy=-16;
3659
3660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3661
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3662 {
3663 24 tempitemx=tmpscr->stairx;
3664 24 tempitemy=tmpscr->stairy+playing_field_offset;
3665 24 }
3666
3667 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3668 48 }
3669 }
3670 2034 }
3671 }
3672 16332 }
3673
3674 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3675
3676 7997 void draw_lens_over()
3677 {
3678 // Oh, what the heck.
3679 static BITMAP *lens_scr = NULL;
3680 static int32_t last_width = -1;
3681 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3682
3683 // Only redraw the circle if the size has changed
3684
2/2
✓ Branch 0 taken 7987 times.
✓ Branch 1 taken 10 times.
7997 if(width != last_width)
3685 {
3686
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(lens_scr == NULL)
3687 {
3688 10 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3689 10 }
3690
3691 10 clear_to_color(lens_scr, BLACK);
3692 10 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3693 10 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3694 10 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3695 10 last_width=width;
3696 10 }
3697
3698 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3699 7997 do_primitives(framebuf, SPLAYER_LENS_OVER, tmpscr, 0, playing_field_offset);
3700 7997 }
3701
3702 //----------------------------------------------------------------
3703
3704 31111 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3705 {
3706 //recreating a big bitmap every frame is highly sluggish.
3707
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 31108 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
31111 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3708 31111 clear_to_color(wavebuf, BLACK);
3709 31111 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3710
3711 int32_t ofs;
3712 // int32_t amplitude=8;
3713 // int32_t wavelength=4;
3714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31111 times.
31111 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3715
3/6
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3716 31111 int32_t amp2=168;
3717
2/4
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3718 31111 int32_t i=frame%amp2;
3719
3720
2/2
✓ Branch 0 taken 5226648 times.
✓ Branch 1 taken 31111 times.
5257759 for(int32_t j=0; j<168; j++)
3721 {
3722
3/4
✓ Branch 0 taken 2613324 times.
✓ Branch 1 taken 2613324 times.
✓ Branch 2 taken 2613324 times.
✗ Branch 3 not taken.
5226648 if(j&1 && interpol)
3723 {
3724 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3725 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3726 }
3727 else
3728 {
3729 5226648 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3730 }
3731
3732
1/2
✓ Branch 0 taken 5226648 times.
✗ Branch 1 not taken.
5226648 if(ofs)
3733 {
3734
2/2
✓ Branch 0 taken 1338021888 times.
✓ Branch 1 taken 5226648 times.
1343248536 for(int32_t k=0; k<256; k++)
3735 {
3736 1338021888 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3737 1338021888 }
3738 5226648 }
3739 5226648 }
3740 31111 }
3741
3742 4848 void draw_fuzzy(int32_t fuzz)
3743 // draws from right half of scrollbuf to framebuf
3744 {
3745 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3746 byte *start, *si, *di;
3747
3748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4848 times.
4848 if(fuzz<1)
3749 fuzz = 1;
3750
3751 4848 xstep = 128%fuzz;
3752
3753
2/2
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 3838 times.
4848 if(xstep > 0)
3754 3838 xstep = fuzz-xstep;
3755
3756 4848 ystep = 112%fuzz;
3757
3758
2/2
✓ Branch 0 taken 1414 times.
✓ Branch 1 taken 3434 times.
4848 if(ystep > 0)
3759 3434 ystep = fuzz-ystep;
3760
3761 4848 firsty = 1;
3762
3763
2/2
✓ Branch 0 taken 4848 times.
✓ Branch 1 taken 174932 times.
179780 for(y=0; y<224;)
3764 {
3765 174932 start = &(scrollbuf->line[y][256]);
3766
3767
4/4
✓ Branch 0 taken 172508 times.
✓ Branch 1 taken 1088376 times.
✓ Branch 2 taken 1085952 times.
✓ Branch 3 taken 174932 times.
1260884 for(dy=0; dy<ystep && dy+y<224; dy++)
3768 {
3769 1085952 si = start;
3770 1085952 di = &(framebuf->line[y+dy][0]);
3771 1085952 i = xstep;
3772 1085952 firstx = 1;
3773
3774
2/2
✓ Branch 0 taken 278003712 times.
✓ Branch 1 taken 1085952 times.
279089664 for(dx=0; dx<256; dx++)
3775 {
3776 278003712 *(di++) = *si;
3777
3778
2/2
✓ Branch 0 taken 234248896 times.
✓ Branch 1 taken 43754816 times.
278003712 if(++i >= fuzz)
3779 {
3780
2/2
✓ Branch 0 taken 42668864 times.
✓ Branch 1 taken 1085952 times.
43754816 if(!firstx)
3781 42668864 si += fuzz;
3782 else
3783 {
3784 1085952 si += fuzz-xstep;
3785 1085952 firstx = 0;
3786 }
3787
3788 43754816 i = 0;
3789 43754816 }
3790 278003712 }
3791 1085952 }
3792
3793
2/2
✓ Branch 0 taken 170084 times.
✓ Branch 1 taken 4848 times.
174932 if(!firsty)
3794 170084 y += fuzz;
3795 else
3796 {
3797 4848 y += ystep;
3798 4848 ystep = fuzz;
3799 4848 firsty = 0;
3800 }
3801 }
3802 4848 }
3803
3804 9285763 void updatescr(bool allowwavy)
3805 {
3806
4/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 9285648 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
✓ Branch 4 taken 115 times.
✗ Branch 5 not taken.
9285763 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3807
4/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 9285648 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 115 times.
9285763 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3808
3809
2/2
✓ Branch 0 taken 9258998 times.
✓ Branch 1 taken 26765 times.
9285763 if(toogam)
3810 {
3811 26765 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3812 26765 }
3813
3814
1/2
✓ Branch 0 taken 9285763 times.
✗ Branch 1 not taken.
9285763 if(Showpal)
3815 dump_pal(framebuf);
3816
3817
2/2
✓ Branch 0 taken 8984531 times.
✓ Branch 1 taken 301232 times.
9285763 if(!Playing)
3818 301232 black_opening_count=0;
3819
3820
2/2
✓ Branch 0 taken 9212503 times.
✓ Branch 1 taken 73260 times.
9285763 if(black_opening_count<0) //shape is opening up
3821 {
3822 73260 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3823
3824
2/4
✓ Branch 0 taken 73260 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73260 times.
73260 if(Advance||(!Paused))
3825 {
3826 73260 ++black_opening_count;
3827 73260 }
3828 73260 }
3829
2/2
✓ Branch 0 taken 9186367 times.
✓ Branch 1 taken 26136 times.
9212503 else if(black_opening_count>0) //shape is closing
3830 {
3831 26136 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3832
3833
2/4
✓ Branch 0 taken 26136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26136 times.
26136 if(Advance||(!Paused))
3834 {
3835 26136 --black_opening_count;
3836 26136 }
3837 26136 }
3838
3839
3/4
✓ Branch 0 taken 9187873 times.
✓ Branch 1 taken 97890 times.
✓ Branch 2 taken 9187873 times.
✗ Branch 3 not taken.
9285763 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3840 {
3841 black_opening_shape = bosCIRCLE;
3842 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3843 refreshTints();
3844 refreshpal=true;
3845 }
3846
3847
2/2
✓ Branch 0 taken 9031564 times.
✓ Branch 1 taken 254199 times.
9285763 if(refreshpal)
3848 {
3849 254199 refreshpal=false;
3850 254199 RAMpal[253] = _RGB(0,0,0);
3851 254199 RAMpal[254] = _RGB(63,63,63);
3852 254199 hw_palette = &RAMpal;
3853 254199 update_hw_pal = true;
3854
3855 254199 create_rgb_table(&rgb_table, RAMpal, NULL);
3856 254199 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3857 254199 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3858
3859
2/2
✓ Branch 0 taken 65074944 times.
✓ Branch 1 taken 254199 times.
65329143 for(int32_t q=0; q<PAL_SIZE; q++)
3860 {
3861 65074944 trans_table2.data[0][q] = q;
3862 65074944 trans_table2.data[q][q] = q;
3863 65074944 }
3864 254199 }
3865
3866 9285763 bool clearwavy = (wavy <= 0);
3867
3868
2/2
✓ Branch 0 taken 7655 times.
✓ Branch 1 taken 9278108 times.
9285763 if(wavy <= 0)
3869 {
3870 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3871 9278108 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3872 9278108 }
3873
3874 9285763 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3875
3876
6/6
✓ Branch 0 taken 31361 times.
✓ Branch 1 taken 9254402 times.
✓ Branch 2 taken 31239 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 31111 times.
9285763 if(wavy && Playing && allowwavy)
3877 {
3878 31111 draw_wavy(framebuf, wavybuf, wavy,false);
3879 31111 }
3880
3881
2/2
✓ Branch 0 taken 9278108 times.
✓ Branch 1 taken 7655 times.
9285763 if(clearwavy)
3882 9278108 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3883
2/4
✓ Branch 0 taken 7655 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7655 times.
7655 else if(Playing && !Paused)
3884 7655 wavy--; // Wavy was set by a script. Decrement it.
3885
3886
5/6
✓ Branch 0 taken 8984531 times.
✓ Branch 1 taken 301232 times.
✓ Branch 2 taken 259415 times.
✓ Branch 3 taken 8725116 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 259415 times.
9285763 if(Playing && msgpos && !screenscrolling)
3887 {
3888
1/2
✓ Branch 0 taken 259415 times.
✗ Branch 1 not taken.
259415 if(!(msg_bg_display_buf->clip))
3889 259415 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3890
1/2
✓ Branch 0 taken 259415 times.
✗ Branch 1 not taken.
259415 if(!(msg_portrait_display_buf->clip))
3891 259415 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3892
1/2
✓ Branch 0 taken 259415 times.
✗ Branch 1 not taken.
259415 if(!(msg_txt_display_buf->clip))
3893 259415 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3894 259415 }
3895
3896 /*
3897 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3898 {
3899 BITMAP* subBmp = 0;
3900 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3901 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3902 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3903 destroy_bitmap(subBmp);
3904 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3905 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3906 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3907 }
3908 */
3909
3910
2/2
✓ Branch 0 taken 9244706 times.
✓ Branch 1 taken 41057 times.
9285763 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3911
3912
2/2
✓ Branch 0 taken 9249331 times.
✓ Branch 1 taken 36432 times.
9285763 if(nosubscr)
3913 {
3914 36432 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3915 36432 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3916 36432 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3917 36432 }
3918
3919 //TODO: Optimize blit 'overcalls' -Gleeok
3920
2/2
✓ Branch 0 taken 36432 times.
✓ Branch 1 taken 9249331 times.
9285763 BITMAP *source = nosubscr ? panorama : wavybuf;
3921 9285763 blit(source,framebuf,0,0,0,0,256,224);
3922
3923 9285763 update_hw_screen();
3924 9285763 }
3925
3926 //----------------------------------------------------------------
3927
3928 static PALETTE syspal;
3929 int32_t onGUISnapshot()
3930 {
3931 char buf[200];
3932 int32_t num=0;
3933 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3934 do
3935 {
3936 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3937 }
3938 while(num<99999 && exists(buf));
3939
3940 BITMAP *b = create_bitmap_ex(8,resx,resy);
3941
3942 if(b)
3943 {
3944 blit(screen,b,0,0,0,0,resx,resy);
3945 save_bitmap(buf,screen,RAMpal);
3946 destroy_bitmap(b);
3947 }
3948
3949 return D_O_K;
3950 }
3951
3952 int32_t onNonGUISnapshot()
3953 {
3954 PALETTE temppal;
3955 get_palette(temppal);
3956 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3957
3958 char buf[200];
3959 int32_t num=0;
3960
3961 do
3962 {
3963 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3964 }
3965 while(num<99999 && exists(buf));
3966
3967 if (tmpscr->flags3&fNOSUBSCR && !(key[KEY_ALT]))
3968 {
3969 BITMAP *b = create_bitmap_ex(8,256,168);
3970 clear_to_color(b,0);
3971 blit(framebuf,b,0,passive_subscreen_height/2,0,0,256,168);
3972 save_bitmap(buf,b,realpal?temppal:RAMpal);
3973 destroy_bitmap(b);
3974 }
3975 else
3976 {
3977 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3978 }
3979
3980 return D_O_K;
3981 }
3982
3983 int32_t onSnapshot()
3984 {
3985 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3986 {
3987 onGUISnapshot();
3988 }
3989 else
3990 {
3991 onNonGUISnapshot();
3992 }
3993
3994 return D_O_K;
3995 }
3996
3997 int32_t onSaveMapPic()
3998 {
3999 int32_t mapres2 = 0;
4000 char buf[200];
4001 int32_t num=0;
4002 mapscr tmpscr_b[2];
4003 mapscr tmpscr_c[6];
4004 BITMAP* _screen_draw_buffer = NULL;
4005 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4006 set_clip_state(_screen_draw_buffer,1);
4007
4008 for(int32_t i=0; i<6; ++i)
4009 {
4010 tmpscr_c[i] = tmpscr2[i];
4011 tmpscr2[i].zero_memory();
4012
4013 if(i>=2)
4014 {
4015 continue;
4016 }
4017
4018 tmpscr_b[i] = tmpscr[i];
4019 tmpscr[i].zero_memory();
4020 }
4021
4022 do
4023 {
4024 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4025 }
4026 while(num<99999 && exists(buf));
4027
4028 BITMAP* mappic = NULL;
4029
4030
4031 bool done=false, redraw=true;
4032
4033 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4034
4035 if(!mappic)
4036 {
4037 enter_sys_pal();
4038 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4039 exit_sys_pal();
4040 return D_O_K;;
4041 }
4042
4043 // draw the map
4044 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4045
4046 for(int32_t y=0; y<8; y++)
4047 {
4048 for(int32_t x=0; x<16; x++)
4049 {
4050 if(!displayOnMap(x, y))
4051 {
4052 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4053 }
4054 else
4055 {
4056 int32_t s = (y<<4) + x;
4057 loadscr2(1,s,-1);
4058
4059 for(int32_t i=0; i<6; i++)
4060 {
4061 if(tmpscr[1].layermap[i]<=0)
4062 continue;
4063
4064 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4065 }
4066
4067 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4068
4069 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4070
4071 if(lenscheck(tmpscr+1,0)) putscr(_screen_draw_buffer,256,0,tmpscr+1);
4072 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4073
4074 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4075
4076 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4077 if(get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
4078 {
4079 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4080 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
4081 {
4082 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4083 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4084 }
4085 }
4086 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4087
4088 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4089
4090 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4091 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4092 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
4093 {
4094 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4095 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4096 }
4097 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4098 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4099
4100 }
4101
4102 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4103 }
4104 }
4105
4106 for(int32_t i=0; i<6; ++i)
4107 {
4108 tmpscr2[i]=tmpscr_c[i];
4109
4110 if(i>=2)
4111 {
4112 continue;
4113 }
4114
4115 tmpscr[i]=tmpscr_b[i];
4116 }
4117
4118 save_bitmap(buf,mappic,RAMpal);
4119 destroy_bitmap(mappic);
4120 destroy_bitmap(_screen_draw_buffer);
4121 return D_O_K;
4122 }
4123
4124 14 void f_Quit(int32_t type)
4125 {
4126
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4127 return;
4128
4129 14 bool from_menu = is_sys_pal;
4130
4131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4132 {
4133 14 music_pause();
4134 14 pause_all_sfx();
4135 14 sys_mouse();
4136 14 }
4137 14 enter_sys_pal();
4138 14 clear_keybuf();
4139
4140
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (replay_version_check(0, 10))
4141 13 replay_poll();
4142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4143 14 replay_peek_quit();
4144
4145
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4146 switch(type)
4147 {
4148 case qQUIT:
4149 onQuit();
4150 break;
4151
4152 case qRESET:
4153 onReset();
4154 break;
4155
4156 case qEXIT:
4157 onExit();
4158 break;
4159 }
4160
4161
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4162 {
4163 14 kill_sfx();
4164 14 music_stop();
4165 14 exit_sys_pal();
4166 14 update_hw_screen();
4167 14 }
4168 else
4169 {
4170 exit_sys_pal();
4171 if(!from_menu)
4172 {
4173 music_resume();
4174 resume_all_sfx();
4175 }
4176 }
4177
4178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4179 14 game_mouse();
4180 14 eat_buttons();
4181
4182 14 zc_readrawkey(KEY_ESC);
4183
4184 14 zc_readrawkey(KEY_ENTER);
4185 14 }
4186
4187 //----------------------------------------------------------------
4188
4189 int32_t onNoWalls()
4190 {
4191 cheats_enqueue(Cheat::Walls);
4192 return D_O_K;
4193 }
4194
4195 int32_t onIgnoreSideview()
4196 {
4197 cheats_enqueue(Cheat::IgnoreSideView);
4198 return D_O_K;
4199 }
4200
4201 9285637 int32_t input_idle(bool checkmouse)
4202 {
4203 static int32_t mx, my, mz, mb;
4204
4205
4/6
✓ Branch 0 taken 9285637 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461398 times.
✓ Branch 3 taken 6824239 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2461398 times.
11747035 if(keypressed() || zc_key_pressed() ||
4206
4/8
✓ Branch 0 taken 2461398 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461398 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2461398 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2461398 times.
✗ Branch 7 not taken.
2461398 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4207 {
4208 6824239 idle_count = 0;
4209
4210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6824239 times.
6824239 if(active_count < MAX_ACTIVE)
4211 {
4212 6824239 ++active_count;
4213 6824239 }
4214 6824239 }
4215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2461398 times.
2461398 else if(idle_count < MAX_IDLE)
4216 {
4217 2461398 ++idle_count;
4218 2461398 active_count = 0;
4219 2461398 }
4220
4221 9285637 mx = mouse_x;
4222 9285637 my = mouse_y;
4223 9285637 mz = mouse_z;
4224 9285637 mb = mouse_b;
4225
4226 9285637 return idle_count;
4227 }
4228
4229 int32_t onGoFast()
4230 {
4231 cheats_enqueue(Cheat::Fast);
4232 return D_O_K;
4233 }
4234
4235 int32_t onKillCheat()
4236 {
4237 cheats_enqueue(Cheat::Kill);
4238 return D_O_K;
4239 }
4240
4241 int32_t onSecretsCheat()
4242 {
4243 cheats_enqueue(Cheat::TrigSecrets);
4244 return D_O_K;
4245 }
4246 int32_t onSecretsCheatPerm()
4247 {
4248 cheats_enqueue(Cheat::TrigSecretsPerm);
4249 return D_O_K;
4250 }
4251
4252 int32_t onShowLayer0()
4253 {
4254 show_layer_0 = !show_layer_0;
4255 return D_O_K;
4256 }
4257 int32_t onShowLayer1()
4258 {
4259 show_layer_1 = !show_layer_1;
4260 return D_O_K;
4261 }
4262 int32_t onShowLayer2()
4263 {
4264 show_layer_2 = !show_layer_2;
4265 return D_O_K;
4266 }
4267 int32_t onShowLayer3()
4268 {
4269 show_layer_3 = !show_layer_3;
4270 return D_O_K;
4271 }
4272 int32_t onShowLayer4()
4273 {
4274 show_layer_4 = !show_layer_4;
4275 return D_O_K;
4276 }
4277 int32_t onShowLayer5()
4278 {
4279 show_layer_5 = !show_layer_5;
4280 return D_O_K;
4281 }
4282 int32_t onShowLayer6()
4283 {
4284 show_layer_6 = !show_layer_6;
4285 return D_O_K;
4286 }
4287 int32_t onShowLayerO()
4288 {
4289 show_layer_over=!show_layer_over;
4290 return D_O_K;
4291 }
4292 int32_t onShowLayerP()
4293 {
4294 show_layer_push=!show_layer_push;
4295 return D_O_K;
4296 }
4297 int32_t onShowLayerS()
4298 {
4299 show_sprites=!show_sprites;
4300 return D_O_K;
4301 }
4302 int32_t onShowLayerF()
4303 {
4304 show_ffcs=!show_ffcs;
4305 return D_O_K;
4306 }
4307 int32_t onShowLayerW()
4308 {
4309 show_walkflags=!show_walkflags;
4310 if(show_walkflags)
4311 show_effectflags = false;
4312 return D_O_K;
4313 }
4314 int32_t onShowLayerE()
4315 {
4316 show_effectflags=!show_effectflags;
4317 if(show_effectflags)
4318 show_walkflags = false;
4319 return D_O_K;
4320 }
4321 int32_t onShowFFScripts()
4322 {
4323 show_ff_scripts=!show_ff_scripts;
4324 return D_O_K;
4325 }
4326 int32_t onShowHitboxes()
4327 {
4328 show_hitboxes=!show_hitboxes;
4329 return D_O_K;
4330 }
4331 int32_t onShowInfoOpacity()
4332 {
4333 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4334 zc_set_config("zc","debug_info_opacity",info_opacity);
4335 return D_O_K;
4336 }
4337
4338 int32_t onLightSwitch()
4339 {
4340 cheats_enqueue(Cheat::Light);
4341 return D_O_K;
4342 }
4343
4344 int32_t onGoTo();
4345 int32_t onGoToComplete();
4346
4347 9285637 bool handle_close_btn_quit()
4348 {
4349
1/2
✓ Branch 0 taken 9285637 times.
✗ Branch 1 not taken.
9285637 if(close_button_quit)
4350 {
4351 close_button_quit=false;
4352 f_Quit(qEXIT);
4353 }
4354 9285637 return (exiting_program = Quit==qEXIT);
4355 }
4356
4357 9285637 void syskeys()
4358 {
4359 9285637 update_system_keys();
4360
4361 int32_t oldtitle_version;
4362
4363 9285637 poll_joystick();
4364
4365 9285637 handle_close_btn_quit();
4366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9285637 times.
9285637 if(Quit == qEXIT) return;
4367
4368
2/10
✓ Branch 0 taken 9285637 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9285637 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
9285637 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4369 {
4370 System();
4371 }
4372
4373 9285637 mouse_down=gui_mouse_b();
4374
4375
1/2
✓ Branch 0 taken 9285637 times.
✗ Branch 1 not taken.
9285637 if(zc_read_system_key(KEY_F1))
4376 {
4377 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4378 {
4379 halt=!halt;
4380 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4381 }
4382 else
4383 {
4384 Throttlefps=!Throttlefps;
4385 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4386 }
4387 }
4388
4389 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4390 /*
4391 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4392 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4393 */
4394
4395
1/2
✓ Branch 0 taken 9285637 times.
✗ Branch 1 not taken.
9285637 if(zc_read_system_key(KEY_F2))
4396 {
4397 ShowFPS=!ShowFPS;
4398 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4399 }
4400
4401
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9285637 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9285637 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4402
4403
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9285637 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9285637 if(zc_read_system_key(KEY_F4) && Playing)
4404 {
4405 Paused=true;
4406 Advance=true;
4407 }
4408
4409
1/2
✓ Branch 0 taken 9285637 times.
✗ Branch 1 not taken.
9285637 if(zc_read_system_key(KEY_F6)) onTryQuit();
4410
4411 #ifndef ALLEGRO_MACOSX
4412
1/2
✓ Branch 0 taken 9285637 times.
✗ Branch 1 not taken.
9285637 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4413
4414
1/2
✓ Branch 0 taken 9285637 times.
✗ Branch 1 not taken.
9285637 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4415 #else
4416 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4417
4418 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4419 #endif
4420
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 9285637 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9285637 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4421
4422
1/2
✓ Branch 0 taken 9285637 times.
✗ Branch 1 not taken.
9285637 if (zc_read_system_key(KEY_F12))
4423 {
4424 onSnapshot();
4425 }
4426
4427
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9285637 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9285637 if(debug_enabled && zc_read_system_key(KEY_TAB))
4428 set_debug(!get_debug());
4429
4430
1/2
✓ Branch 0 taken 9285637 times.
✗ Branch 1 not taken.
9285637 if(CheatModifierKeys())
4431 {
4432 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4433 {
4434 if(!bindable_cheat(c))
4435 continue;
4436 if(get_debug() || cheat >= cheat_lvl(c))
4437 {
4438 if(checkcheat(c))
4439 cheats_hit_bind(c);
4440 }
4441 }
4442 }
4443
4444
1/2
✓ Branch 0 taken 9285637 times.
✗ Branch 1 not taken.
9285637 if(volkeys)
4445 {
4446 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4447
4448 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4449
4450 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4451
4452 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4453 }
4454
4455
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9285637 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9285637 if(!get_debug() || !SystemKeys || replay_is_replaying())
4456 9285637 goto bottom;
4457
4458 if(zc_readkey(KEY_D))
4459 {
4460 details = !details;
4461 rectfill(screen,0,0,319,7,BLACK);
4462 rectfill(screen,0,8,31,239,BLACK);
4463 rectfill(screen,288,8,319,239,BLACK);
4464 rectfill(screen,32,232,287,239,BLACK);
4465 }
4466
4467 if(zc_readkey(KEY_P)) Paused=!Paused;
4468
4469 //if(zc_readkey(KEY_P)) centerHero();
4470 if(zc_readkey(KEY_A))
4471 {
4472 Paused=true;
4473 Advance=true;
4474 }
4475
4476 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4477 #ifndef ALLEGRO_MACOSX
4478 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4479
4480 if(zc_readkey(KEY_F7))
4481 {
4482 Matrix(ss_speed, ss_density, 0);
4483 game_pal();
4484 }
4485 #else
4486 // The reason these are different on Mac in the first place is that
4487 // the OS doesn't let us use F9 and F10...
4488 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4489
4490 if(zc_readkey(KEY_F9))
4491 {
4492 Matrix(ss_speed, ss_density, 0);
4493 game_pal();
4494 }
4495 #endif
4496 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4497 {
4498 //change containers
4499 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4500 {
4501 //magic containers
4502 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4503 {
4504 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4505 }
4506 else
4507 {
4508 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4509 }
4510 }
4511 else
4512 {
4513 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4514 {
4515 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4516 }
4517 else
4518 {
4519 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4520 }
4521 }
4522 }
4523
4524 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4525 {
4526 //change containers
4527 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4528 {
4529 //magic containers
4530 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4531 {
4532 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4533 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4534 //heart containers
4535 }
4536 else
4537 {
4538 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4539 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4540 }
4541 }
4542 else
4543 {
4544 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4545 {
4546 game->set_magic(zc_max(game->get_magic()-1,0));
4547 }
4548 else
4549 {
4550 game->set_life(zc_max(game->get_life()-1,0));
4551 }
4552 }
4553 }
4554
4555 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4556
4557 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4558
4559 verifyBothWeapons();
4560
4561 bottom:
4562
4563
1/2
✓ Branch 0 taken 9285637 times.
✗ Branch 1 not taken.
9285637 if(input_idle(true) > after_time())
4564 {
4565 Matrix(ss_speed, ss_density, 0);
4566 game_pal();
4567 }
4568 9285637 }
4569
4570 705774 void checkQuitKeys()
4571 {
4572 #ifndef ALLEGRO_MACOSX
4573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 705774 times.
705774 if(key[KEY_F9]) f_Quit(qRESET);
4574
4575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 705774 times.
705774 if(key[KEY_F10]) f_Quit(qEXIT);
4576 #else
4577 if(key[KEY_F7]) f_Quit(qRESET);
4578
4579 if(key[KEY_F8]) f_Quit(qEXIT);
4580 #endif
4581 705774 }
4582
4583 9285637 bool CheatModifierKeys()
4584 {
4585 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4586 // to trigger cheats.
4587
1/2
✓ Branch 0 taken 9285637 times.
✗ Branch 1 not taken.
9285637 if (replay_is_replaying())
4588 9285637 return false;
4589
4590 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4591 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4592 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4593 {
4594 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4595 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4596 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4597 {
4598 return true;
4599 }
4600 }
4601 return false;
4602 9285637 }
4603
4604 //99:05:54, for some reason?
4605 #define OLDMAXTIME 21405240
4606 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4607 #define MAXTIME 1944000000
4608
4609 9285763 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4610 {
4611
1/2
✓ Branch 0 taken 9285763 times.
✗ Branch 1 not taken.
9285763 if(zcmusic!=NULL)
4612 {
4613 zcmusic_poll();
4614 }
4615 9285763 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
4616
4617 9285763 updatescr(allowwavy);
4618
4619 9285763 Advance=false;
4620
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9285763 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9285763 times.
9285763 while(Paused && !Advance && !Quit)
4621 {
4622 // have to call this, otherwise we'll get an infinite loop
4623 syskeys();
4624 if(allowF6Script)
4625 {
4626 FFCore.runF6Engine();
4627 }
4628 throttleFPS();
4629
4630 #ifdef _WIN32
4631
4632 if(use_dwm_flush)
4633 {
4634 do_DwmFlush();
4635 }
4636
4637 #endif
4638
4639 // to keep music playing
4640 if(zcmusic!=NULL)
4641 {
4642 zcmusic_poll();
4643 }
4644
4645 update_hw_screen();
4646 }
4647
4648
2/2
✓ Branch 0 taken 9285651 times.
✓ Branch 1 taken 112 times.
9285763 if(Quit)
4649 112 return;
4650
4651
3/4
✓ Branch 0 taken 8984522 times.
✓ Branch 1 taken 301129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8984522 times.
9285651 if(Playing && game->get_time()<unsigned(get_qr(qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4652 8984522 game->change_time(1);
4653
4654 // Many mistakes have been make re: inputs, and we are stuck with many replays relying on those mistakes.
4655
4656 9285651 bool should_reset_down_state = !get_qr(qr_BROKEN_INPUT_DOWN_STATE);
4657
2/2
✓ Branch 0 taken 19895 times.
✓ Branch 1 taken 9265756 times.
9285651 if (replay_version_check(0, 16))
4658 9265756 should_reset_down_state = replay_version_check(11, 16);
4659
2/2
✓ Branch 0 taken 6948639 times.
✓ Branch 1 taken 2337012 times.
9285651 if (should_reset_down_state)
4660 {
4661
2/2
✓ Branch 0 taken 42066216 times.
✓ Branch 1 taken 2337012 times.
44403228 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4662 42066216 down_control_states[i] = raw_control_state[i];
4663 2337012 }
4664
4665
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9285637 times.
9285651 if (replay_is_active())
4666 {
4667
2/2
✓ Branch 0 taken 1270449 times.
✓ Branch 1 taken 8015188 times.
9285637 if (replay_version_check(3))
4668 8015188 replay_poll();
4669
4670
4/4
✓ Branch 0 taken 6945057 times.
✓ Branch 1 taken 2340580 times.
✓ Branch 2 taken 100535 times.
✓ Branch 3 taken 6844522 times.
9285637 if (replay_version_check(11) || replay_version_check(6, 8))
4671 2441115 replay_peek_input();
4672 9285637 }
4673
4674 9285651 load_control_called_this_frame = false;
4675
4676 9285651 poll_keyboard();
4677 9285651 update_keys();
4678
4679 9285651 ++frame;
4680
4681
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9285637 times.
9285651 if (replay_is_replaying())
4682 9285637 replay_do_cheats();
4683 9285651 syskeys();
4684
4685 // The mouse variables can change from the mouse thread at anytime during a frame,
4686 // so save the result at the start so that replaying is consistent.
4687 9285651 script_mouse_x = gui_mouse_x();
4688 9285651 script_mouse_y = gui_mouse_y();
4689 9285651 script_mouse_z = mouse_z;
4690 9285651 script_mouse_b = mouse_b;
4691
4692 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4693 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4694 // approach here means it doesn't matter which call adds the cheat.
4695 9285651 cheats_execute_queued();
4696
4697
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9285637 times.
9285651 if (replay_is_replaying())
4698 9285637 replay_peek_quit();
4699
2/2
✓ Branch 0 taken 9285637 times.
✓ Branch 1 taken 14 times.
9285651 if (GameFlags & GAMEFLAG_TRYQUIT)
4700 14 replay_step_quit(0);
4701
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 9282717 times.
9285651 if(allowF6Script)
4702 9282717 FFCore.runF6Engine();
4703
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 9285352 times.
9285651 if (Quit)
4704 299 replay_step_quit(Quit);
4705 // Someday... maybe install a Turbo button here?
4706 9285651 throttleFPS();
4707
4708 #ifdef _WIN32
4709
4710 if(use_dwm_flush)
4711 {
4712 do_DwmFlush();
4713 }
4714
4715 #endif
4716
4717 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4718
2/2
✓ Branch 0 taken 68758 times.
✓ Branch 1 taken 9216893 times.
9285651 if(sfxcleanup)
4719 9216893 sfx_cleanup();
4720
4721 9285651 jit_poll();
4722
4723 #ifdef __EMSCRIPTEN__
4724 // Yield the main thread back to the browser occasionally.
4725 if (is_headless())
4726 {
4727 static int rate = 10000;
4728 static int force_yield = rate;
4729 if (force_yield++ >= rate)
4730 {
4731 force_yield = 0;
4732 emscripten_sleep(0);
4733 }
4734 }
4735 #endif
4736
4737
4/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 9285536 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
✓ Branch 4 taken 115 times.
✗ Branch 5 not taken.
9285651 static bool test_mode_auto_restart = zc_get_config("zeldadx", "test_mode_auto_restart", false);
4738
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9285651 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9285651 if (zqtesting_mode && test_mode_auto_restart)
4739 {
4740 static auto last_write_time = fs::last_write_time(qstpath);
4741 static auto last_check = std::chrono::system_clock::now();
4742
4743 if (std::chrono::system_clock::now() - last_check > 200ms)
4744 {
4745 last_check = std::chrono::system_clock::now();
4746 auto write_time = fs::last_write_time(qstpath);
4747 if (last_write_time != write_time)
4748 {
4749 last_write_time = write_time;
4750 disableClickToFreeze = false;
4751 Quit = qRESET;
4752 replay_quit();
4753 }
4754 }
4755 }
4756 9285763 }
4757
4758 101 void zapout()
4759 {
4760 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4761 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4762
4763 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4764 101 script_drawing_commands.Clear();
4765
4766 // zap out
4767
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=1; i<=24; i++)
4768 {
4769 2424 draw_fuzzy(i);
4770 2424 advanceframe(true);
4771
4772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4773 {
4774 break;
4775 }
4776 2424 }
4777 101 }
4778
4779 101 void zapin()
4780 {
4781 101 FFCore.warpScriptCheck();
4782 101 draw_screen(tmpscr);
4783 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4784 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4785 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4786
4787 // zap out
4788 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4789
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=24; i>=1; i--)
4790 {
4791 2424 draw_fuzzy(i);
4792 2424 advanceframe(true);
4793
4794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4795 {
4796 break;
4797 }
4798 2424 }
4799 101 }
4800
4801
4802 65 void wavyout(bool showhero)
4803 {
4804 65 draw_screen(tmpscr, showhero);
4805 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4806
4807 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4808 65 clear_to_color(wavebuf,0);
4809 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4810
4811 static PALETTE wavepal;
4812
4813 int32_t ofs;
4814 65 int32_t amplitude=8;
4815
4816 65 int32_t wavelength=4;
4817 65 double palpos=0, palstep=4, palstop=126;
4818
4819 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4820
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4821 {
4822
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4823 {
4824 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4825 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4826 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4827 698880 }
4828
4829 2730 palpos+=palstep;
4830
4831
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4832 {
4833 2730 hw_palette = &wavepal;
4834 2730 update_hw_pal = true;
4835 2730 }
4836 else
4837 {
4838 hw_palette = &RAMpal;
4839 update_hw_pal = true;
4840 }
4841
4842
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4843 {
4844
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4845 {
4846 117411840 ofs=0;
4847
4848
4/4
✓ Branch 0 taken 57308160 times.
✓ Branch 1 taken 60103680 times.
✓ Branch 2 taken 28654080 times.
✓ Branch 3 taken 28654080 times.
117411840 if((j<i)&&(j&1))
4849 {
4850 28654080 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4851 28654080 }
4852
4853 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4854 117411840 }
4855 458640 }
4856
4857 2730 advanceframe(true);
4858
4859 // animate_combos();
4860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4861 break;
4862 2730 }
4863
4864 65 destroy_bitmap(wavebuf);
4865 65 }
4866
4867 65 void wavyin()
4868 {
4869 65 draw_screen(tmpscr);
4870 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4871
4872 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4873 65 clear_to_color(wavebuf,0);
4874 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4875
4876 static PALETTE wavepal;
4877
4878 //Breaks dark rooms.
4879 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4880 /*
4881 loadfullpal();
4882 loadlvlpal(DMaps[currdmap].color);
4883 ringcolor(false);
4884 */
4885 65 refreshpal=false;
4886 int32_t ofs;
4887 65 int32_t amplitude=8;
4888 65 int32_t wavelength=4;
4889 65 double palpos=168, palstep=4, palstop=126;
4890
4891 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4892
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4893 {
4894
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4895 {
4896 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4897 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4898 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4899 698880 }
4900
4901 2730 palpos-=palstep;
4902
4903
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4904 {
4905 2730 hw_palette = &wavepal;
4906 2730 update_hw_pal = true;
4907 2730 }
4908 else
4909 {
4910 hw_palette = &RAMpal;
4911 update_hw_pal = true;
4912 }
4913
4914
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4915 {
4916
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4917 {
4918 117411840 ofs=0;
4919
4920
4/4
✓ Branch 0 taken 59404800 times.
✓ Branch 1 taken 58007040 times.
✓ Branch 2 taken 30051840 times.
✓ Branch 3 taken 29352960 times.
117411840 if((j<(167-i))&&(j&1))
4921 {
4922 29352960 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4923 29352960 }
4924
4925 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4926 117411840 }
4927 458640 }
4928
4929 2730 advanceframe(true);
4930 // animate_combos();
4931
4932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4933 break;
4934 2730 }
4935
4936 65 destroy_bitmap(wavebuf);
4937 65 }
4938
4939 2168 void blackscr(int32_t fcnt,bool showsubscr)
4940 {
4941 2168 reset_pal_cycling();
4942 2168 script_drawing_commands.Clear();
4943
4944 2168 FFCore.warpScriptCheck();
4945 2168 bool showtime = game->should_show_time();
4946
2/2
✓ Branch 0 taken 2168 times.
✓ Branch 1 taken 64970 times.
67138 while(fcnt>0)
4947 {
4948 64970 clear_bitmap(framebuf);
4949
4950
2/2
✓ Branch 0 taken 25080 times.
✓ Branch 1 taken 39890 times.
64970 if(showsubscr)
4951 {
4952 39890 put_passive_subscr(framebuf,0,passive_subscreen_offset,showtime,sspUP);
4953
3/4
✓ Branch 0 taken 39890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 39140 times.
39890 if(get_qr(qr_SCRIPTDRAWSINWARPS) || (get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4954 {
4955 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4956 750 }
4957 39890 }
4958
4959 64970 advanceframe(true);
4960
4961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64970 times.
64970 if(Quit)
4962 break;
4963
4964 64970 --fcnt;
4965 }
4966 2168 }
4967
4968 1011 void openscreen(int32_t shape)
4969 {
4970 1011 reset_pal_cycling();
4971 1011 black_opening_count=0;
4972
4973
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 911 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
1011 if(COOLSCROLL || shape>-1)
4974 {
4975 911 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4976 911 return;
4977 }
4978 else
4979 {
4980 100 Hero.setDontDraw(true);
4981 100 show_subscreen_dmap_dots=false;
4982 100 show_subscreen_numbers=false;
4983 // show_subscreen_items=false;
4984 100 show_subscreen_life=false;
4985 }
4986
4987 100 int32_t x=128;
4988
4989 100 FFCore.warpScriptCheck();
4990
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 8000 times.
8100 for(int32_t i=0; i<80; i++)
4991 {
4992 8000 draw_screen(tmpscr);
4993 //? draw_screen already draws the subscreen -DD
4994 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4995 8000 x=128-(((i*128/80)/8)*8);
4996
4997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(x>0)
4998 {
4999 8000 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5000 8000 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5001 8000 }
5002
5003 8000 advanceframe(true);
5004
5005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(Quit)
5006 {
5007 break;
5008 }
5009 8000 }
5010
5011 100 Hero.setDontDraw(false);
5012 100 show_subscreen_items=true;
5013 100 show_subscreen_dmap_dots=true;
5014 1011 }
5015
5016 void closescreen(int32_t shape)
5017 {
5018 reset_pal_cycling();
5019 black_opening_count=0;
5020
5021 if(COOLSCROLL || shape>-1)
5022 {
5023 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5024 return;
5025 }
5026 else
5027 {
5028 Hero.setDontDraw(true);
5029 show_subscreen_dmap_dots=false;
5030 show_subscreen_numbers=false;
5031 // show_subscreen_items=false;
5032 show_subscreen_life=false;
5033 }
5034
5035 int32_t x=128;
5036
5037 FFCore.warpScriptCheck();
5038 for(int32_t i=79; i>=0; --i)
5039 {
5040 draw_screen(tmpscr);
5041 //? draw_screen already draws the subscreen -DD
5042 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
5043 x=128-(((i*128/80)/8)*8);
5044
5045 if(x>0)
5046 {
5047 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5048 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5049 }
5050
5051 advanceframe(true);
5052
5053 if(Quit)
5054 {
5055 break;
5056 }
5057 }
5058
5059 Hero.setDontDraw(false);
5060 show_subscreen_items=true;
5061 show_subscreen_dmap_dots=true;
5062 }
5063
5064 179 int32_t TriforceCount()
5065 {
5066 179 int32_t c=0;
5067
5068
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 179 times.
1611 for(int32_t i=1; i<=8; i++)
5069
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 1044 times.
2476 if(game->lvlitems[i]&liTRIFORCE)
5070 1044 ++c;
5071
5072 179 return c;
5073 }
5074
5075 int32_t onCustomGame()
5076 {
5077 int32_t file = getsaveslot();
5078
5079 if(file < 0)
5080 return D_O_K;
5081
5082 bool ret = (custom_game(file)!=0);
5083 return ret ? D_CLOSE : D_O_K;
5084 }
5085
5086 int32_t onContinue()
5087 {
5088 return D_CLOSE;
5089 }
5090
5091 int32_t onEsc() // Unused?? -L
5092 {
5093 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5094 }
5095
5096 int32_t onVsync()
5097 {
5098 Throttlefps = !Throttlefps;
5099 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5100 return D_O_K;
5101 }
5102
5103 int32_t onWinPosSave()
5104 {
5105 SaveWinPos = !SaveWinPos;
5106 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5107 return D_O_K;
5108 }
5109 int32_t onIntegerScaling()
5110 {
5111 scaleForceInteger = !scaleForceInteger;
5112 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5113 return D_O_K;
5114 }
5115 int32_t onStretchGame()
5116 {
5117 stretchGame = !stretchGame;
5118 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5119 return D_O_K;
5120 }
5121
5122 int32_t onClickToFreeze()
5123 {
5124 ClickToFreeze = !ClickToFreeze;
5125 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5126 return D_O_K;
5127 }
5128
5129 int32_t OnSaveZCConfig()
5130 {
5131 if(jwin_alert3(
5132 "Save Configuration",
5133 "Are you sure that you wish to save your present configuration settings?",
5134 "This will overwrite your prior settings!",
5135 NULL,
5136 "&Yes",
5137 "&No",
5138 NULL,
5139 'y',
5140 'n',
5141 0,
5142 get_zc_font(font_lfont)) == 1)
5143 {
5144 save_game_configs();
5145 return D_O_K;
5146 }
5147 else return D_O_K;
5148 }
5149
5150 int32_t OnnClearQuestDir()
5151 {
5152 if(jwin_alert3(
5153 "Clear Current Directory Cache",
5154 "Are you sure that you wish to clear the current cached directory?",
5155 "This will default the current directory to `<ROOT>/quests` for this instance of ZC Player!",
5156 NULL,
5157 "&Yes",
5158 "&No",
5159 NULL,
5160 'y',
5161 'n',
5162 0,
5163 get_zc_font(font_lfont)) == 1)
5164 {
5165 zc_set_config("zeldadx","quest_dir","");
5166 flush_config_file();
5167 strcpy(qstdir,"");
5168 #ifdef __EMSCRIPTEN__
5169 em_sync_fs();
5170 #endif
5171 return D_O_K;
5172 }
5173 else return D_O_K;
5174 }
5175
5176
5177 int32_t onConsoleZASM()
5178 {
5179 if ( !zasm_debugger )
5180 {
5181 AlertDialog("WARNING: ZASM Debugger",
5182 "Enabling this will open the ZASM Debugger Console"
5183 "\nThis will likely grind ZC to a halt with lag."
5184 "\nTo make any use of this, it is suggested that you read"
5185 "\nthe documentation for 'void Breakpoint(char[] string);'"
5186 " in 'ZScript_Additions.txt'"
5187 "\nThis is not recommended for normal users,"
5188 " and is only intended for ZC developers,"
5189 "\nor quest developers coding directly in ZASM"
5190 "\nAre you sure that you wish to open the ZASM Debugger?",
5191 [&](bool ret,bool)
5192 {
5193 if(ret)
5194 {
5195 FFCore.ZASMPrint(true);
5196 }
5197 }).show();
5198 return D_O_K;
5199 }
5200 else
5201 {
5202 FFCore.ZASMPrint(false);
5203 return D_O_K;
5204 }
5205 }
5206
5207
5208 int32_t onConsoleZScript()
5209 {
5210 if ( !zscript_debugger )
5211 {
5212 AlertDialog("ZScript Debugger",
5213 "Enabling this will open the ZScript Debugger Console"
5214 "\nThis will display any messages logged by scripts,"
5215 " including script errors."
5216 "\nAre you sure that you wish to open the ZScript Debugger?",
5217 [&](bool ret,bool)
5218 {
5219 if(ret)
5220 {
5221 FFCore.ZScriptConsole(true);
5222 }
5223 }).show();
5224 return D_O_K;
5225 }
5226 else
5227 {
5228 FFCore.ZScriptConsole(false);
5229 return D_O_K;
5230 }
5231 }
5232
5233 int32_t onClrConsoleOnReload()
5234 {
5235 clearConsoleOnReload = !clearConsoleOnReload;
5236 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5237 return D_O_K;
5238 }
5239 int32_t onClrConsoleOnLoad()
5240 {
5241 clearConsoleOnLoad = !clearConsoleOnLoad;
5242 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5243 return D_O_K;
5244 }
5245
5246
5247 int32_t onFrameSkip()
5248 {
5249 FrameSkip = !FrameSkip;
5250 return D_O_K;
5251 }
5252
5253 int32_t onSaveDragResize()
5254 {
5255 SaveDragResize = !SaveDragResize;
5256 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5257 return D_O_K;
5258 }
5259
5260 int32_t onDragAspect()
5261 {
5262 DragAspect = !DragAspect;
5263 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5264 return D_O_K;
5265 }
5266
5267 int32_t onTransLayers()
5268 {
5269 TransLayers = !TransLayers;
5270 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5271 return D_O_K;
5272 }
5273
5274 int32_t onNESquit()
5275 {
5276 NESquit = !NESquit;
5277 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5278 return D_O_K;
5279 }
5280
5281 int32_t onVolKeys()
5282 {
5283 volkeys = !volkeys;
5284 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5285 return D_O_K;
5286 }
5287
5288 int32_t onShowFPS()
5289 {
5290 ShowFPS = !ShowFPS;
5291 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5292 return D_O_K;
5293 }
5294
5295 1095705166 bool is_Fkey(int32_t k)
5296 {
5297
2/2
✓ Branch 0 taken 111427644 times.
✓ Branch 1 taken 984277522 times.
1095705166 switch(k)
5298 {
5299 case KEY_F1:
5300 case KEY_F2:
5301 case KEY_F3:
5302 case KEY_F4:
5303 case KEY_F5:
5304 case KEY_F6:
5305 case KEY_F7:
5306 case KEY_F8:
5307 case KEY_F9:
5308 case KEY_F10:
5309 case KEY_F11:
5310 case KEY_F12:
5311 111427644 return true;
5312 }
5313
5314 984277522 return false;
5315 1095705166 }
5316
5317 void kb_getkey(DIALOG *d);
5318
5319 //Used by all keyboard key settings dialogues.
5320 void kb_clearjoystick(DIALOG *d)
5321 {
5322 d->flags|=D_SELECTED;
5323
5324 jwin_button_proc(MSG_DRAW,d,0);
5325 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5326 // text_mode(vc(11));
5327 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5328 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5329
5330 update_hw_screen(true);
5331
5332 clear_keybuf();
5333 int32_t k = next_press_key();
5334 clear_keybuf();
5335
5336 //shnarf
5337 //47=f1
5338 //59=esc
5339 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5340 // *((int32_t*)d->dp3) = k;
5341 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5342
5343
5344 d->flags&=~D_SELECTED;
5345 }
5346
5347 //Clears key to 0.
5348 //Used by all keyboard key settings dialogues.
5349 void kb_clearkey(DIALOG *d);
5350
5351 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5352 {
5353 switch(msg)
5354 {
5355 case MSG_KEY:
5356 case MSG_CLICK:
5357
5358 kb_clearjoystick(d);
5359
5360 while(gui_mouse_b())
5361 {
5362 clear_keybuf();
5363 rest(1);
5364 }
5365
5366 return D_REDRAW;
5367 }
5368
5369 return jwin_button_proc(msg,d,c);
5370 }
5371
5372 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5373 //Only used in keyboard settings dialogues to clear keys.
5374 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5375
5376 void j_getbtn(DIALOG *d)
5377 {
5378 d->flags|=D_SELECTED;
5379 jwin_button_proc(MSG_DRAW,d,0);
5380 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5381 // text_mode(vc(11));
5382 int32_t y = screen->h/2 - 12;
5383 textout_centre_ex(screen, font, "Press a button", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5384 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5385 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5386
5387 update_hw_screen(true);
5388
5389 int32_t b = next_joy_input(true);
5390
5391 if(b>=0)
5392 *((int32_t*)d->dp3) = b;
5393
5394 d->flags&=~D_SELECTED;
5395
5396 if (player)
5397 player->joy_on = TRUE;
5398 }
5399
5400 void j_getstick(DIALOG *d)
5401 {
5402 d->flags|=D_SELECTED;
5403 jwin_button_proc(MSG_DRAW,d,0);
5404 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5405 // text_mode(vc(11));
5406 int32_t y = screen->h/2 - 12;
5407 textout_centre_ex(screen, font, "Move a stick (or DPAD)", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5408 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5409 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5410
5411 update_hw_screen(true);
5412
5413 int32_t b = next_joy_input(false);
5414
5415 if(b>=0)
5416 *((int32_t*)d->dp3) = b;
5417
5418 d->flags&=~D_SELECTED;
5419
5420 if (player)
5421 player->joy_on = TRUE;
5422 }
5423
5424 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5425 {
5426 switch(msg)
5427 {
5428 case MSG_KEY:
5429 case MSG_CLICK:
5430
5431 j_getbtn(d);
5432
5433 while(gui_mouse_b()) {
5434 rest(1);
5435 clear_keybuf();
5436 }
5437
5438 return D_REDRAW;
5439 }
5440
5441 return jwin_button_proc(msg,d,c);
5442 }
5443
5444 int32_t d_jstick_proc(int32_t msg,DIALOG *d,int32_t c)
5445 {
5446 switch(msg)
5447 {
5448 case MSG_KEY:
5449 case MSG_CLICK:
5450
5451 j_getstick(d);
5452
5453 while(gui_mouse_b()) {
5454 rest(1);
5455 clear_keybuf();
5456 }
5457
5458 return D_REDRAW;
5459 }
5460
5461 return jwin_button_proc(msg,d,c);
5462 }
5463
5464 //shnarf
5465 extern const char *key_str[];
5466 std::string get_keystr(int key);
5467
5468 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5469 //extern int32_t zcmusic_bufsz;
5470
5471 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5472 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80],
5473 str_primary_stick[80], str_secondary_stick[80];
5474
5475 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5476 {
5477 //these are here to bypass compiler warnings about unused arguments
5478 c=c;
5479
5480 if(msg==MSG_DRAW)
5481 {
5482 switch(d->w)
5483 {
5484 case 0:
5485 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5486 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5487 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5488 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5489 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5490 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5491 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5492 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5493 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5494 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5495 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5496 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5497 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5498 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5499 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5500 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5501 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5502 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5503 break;
5504
5505 case 1:
5506 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5507 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5508 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5509 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5510 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5511 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5512 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5513 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5514 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5515 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5516 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5517 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5518 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5519 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5520 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5521 sprintf(str_primary_stick,"%03d\n%s",js_stick_1_x_stick,joystick_name(js_stick_1_x_stick));
5522 sprintf(str_secondary_stick,"%03d\n%s",js_stick_2_x_stick,joystick_name(js_stick_2_x_stick));
5523 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5524 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5525 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5526 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5527 break;
5528
5529 case 2:
5530 sprintf(str_a," %3d",midi_volume);
5531 sprintf(str_b," %3d",digi_volume);
5532 sprintf(str_l," %3d",emusic_volume);
5533 sprintf(str_m," %3dKB",zcmusic_bufsz);
5534 sprintf(str_r," %3d",sfx_volume);
5535 strcpy(str_s,pan_str[pan_style]);
5536 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5537 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5538 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5539 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5540 break;
5541 }
5542 }
5543
5544 return D_O_K;
5545 }
5546
5547 int32_t set_vol(void *dp3, int32_t d2)
5548 {
5549 switch(((int32_t*)dp3)[0])
5550 {
5551 case 0:
5552 midi_volume = zc_min(d2<<3,255);
5553 break;
5554
5555 case 1:
5556 digi_volume = zc_min(d2<<3,255);
5557 break;
5558
5559 case 2:
5560 emusic_volume = zc_min(d2<<3,255);
5561 break;
5562
5563 case 3:
5564 sfx_volume = zc_min(d2<<3,255);
5565 break;
5566 }
5567
5568 // text_mode(vc(11));
5569 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5570 return D_O_K;
5571 }
5572
5573 int32_t set_pan(void *dp3, int32_t d2)
5574 {
5575 pan_style = vbound(d2,0,3);
5576 // text_mode(vc(11));
5577 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5578 return D_O_K;
5579 }
5580
5581 int32_t set_buf(void *dp3, int32_t d2)
5582 {
5583 // text_mode(vc(11));
5584 zcmusic_bufsz = d2 + 1;
5585 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5586 return D_O_K;
5587 }
5588
5589 static int32_t gamepad_joys_list[] =
5590 {
5591 61,
5592 -1
5593 };
5594
5595 static int32_t gamepad_btn_list[] =
5596 {
5597 6,
5598 7,8,9,10,11,12,13,14,15,16,17,
5599 18,19,20,21,22,23,24,25,26,27,28,
5600 29,30,31,32,33,34,35,36,37,38,39,
5601 -1
5602 };
5603
5604 static int32_t gamepad_dirs_list[] =
5605 {
5606 40,41,42,43,
5607 44,45,46,47,
5608 48,49,50,51,
5609 52,53,54,55,
5610 56,57,58,59,
5611 60,
5612 -1
5613 };
5614
5615 static TABPANEL gamepad_tabs[] =
5616 {
5617 // (text)
5618 { (char *)"Controllers", D_SELECTED, gamepad_joys_list, 0, NULL },
5619 { (char *)"Buttons", 0, gamepad_btn_list, 0, NULL },
5620 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5621 { NULL, 0, NULL, 0, NULL }
5622 };
5623
5624 const char *joy_list(int32_t index, int32_t *list_size)
5625 {
5626 if (index == -1)
5627 {
5628 *list_size = al_get_num_joysticks();
5629 return NULL;
5630 }
5631
5632 ALLEGRO_JOYSTICK* joy = al_get_joystick(index);
5633 if (!joy)
5634 {
5635 return "?";
5636 }
5637
5638 return al_get_joystick_name(joy);
5639 }
5640
5641 115 static ListData joy__list(joy_list, &font);
5642
5643 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c)
5644 {
5645 int32_t d2 = d->d2;
5646 int32_t ret = jwin_droplist_proc(msg,d,c);
5647
5648 if(d2!=d->d2)
5649 {
5650 joystick_index = d->d2;
5651 ret |= D_REDRAW_ALL;
5652 }
5653
5654 return ret;
5655 }
5656
5657 static DIALOG gamepad_dlg[] =
5658 {
5659 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5660 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5661 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5662 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5663 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5664 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5665 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5666 // 6
5667 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5668 // 7
5669 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5670 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5671 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5672 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5673 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5674 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5675 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5676 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5677 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5678 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5679 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5680 // 18
5681 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5682 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5683 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5684 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5685 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5686 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5687 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5688 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5689 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5690 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5691 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5692 // 29
5693 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5694 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5695 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5696 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5697 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5698 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5699 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5700 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5701 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5702 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5703 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5704 // 40
5705 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5706 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5707 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5708 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5709 // 44
5710 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5711 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5712 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5713 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5714 // 48
5715 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5716 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5717 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5718 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5719 // 52
5720 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5721 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5722 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5723 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5724 // 56
5725 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Primary: Use Analog Stick (Ignore above and use below instead)", NULL, NULL },
5726 { d_jstick_proc, 22, 165, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Primary", NULL, &js_stick_1_x_stick },
5727 { d_jstick_proc, 22, 195, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Secondary", NULL, &js_stick_2_x_stick },
5728 { jwin_text_proc, 90, 165, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_primary_stick, NULL, NULL },
5729 { jwin_text_proc, 90, 195, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_secondary_stick, NULL, NULL },
5730
5731 // 61
5732 { d_joylist_proc, 22, 62, 150, 16, 0, 0, 0, 0, 0, 0, (void *) &joy__list, NULL, NULL },
5733
5734 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5735 };
5736
5737 static int32_t keyboard_keys_list[] =
5738 {
5739 6,7,8,9,10,
5740 11,12,13,14,15,16,17,18,19,20,
5741 21,22,23,24,25,26,27,28,29,30,
5742 31,32,33,34,35,36,37,38,39,40,
5743 -1
5744 };
5745
5746 static int32_t keyboard_dirs_list[] =
5747 {
5748 41,42,43,44,
5749 45,46,47,48,
5750 49,50,51,52,
5751 53,54,55,56,
5752 -1
5753 };
5754
5755 static int32_t keyboard_mods_list[] =
5756 {
5757 57,58,59,60,
5758 61,62,63,64,
5759 65,66,67,68,
5760 69,70,71,72,
5761 -1
5762 };
5763
5764 static TABPANEL keyboard_control_tabs[] =
5765 {
5766 // (text)
5767 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5768 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5769 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5770 { NULL, 0, NULL, 0, NULL }
5771 };
5772
5773 static DIALOG keyboard_control_dlg[] =
5774 {
5775 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5776 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5777 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5778 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5779 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5780 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5781 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5782 // Keys
5783 // 6
5784 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5785 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5786 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5787 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5788 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5789 // 11
5790 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5791 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5792 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5793 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5794 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5795 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5796 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5797 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5798 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5799 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5800 // 21
5801 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5802 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5803 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5804 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5805 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5806 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5807 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5808 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5809 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5810 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5811 // 31
5812 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5813 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5814 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5815 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5816 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5817 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5818 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5819 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5820 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5821 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5822 // Dirs
5823 // 41
5824 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5825 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5826 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5827 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5828 // 45
5829 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5830 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5831 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5832 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5833 // 49
5834 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5835 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5836 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5837 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5838 // 53
5839 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5840 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5841 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5842 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5843 // Mods
5844 // 57
5845 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5846 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5847 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5848 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5849 // 61
5850 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5851 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5852 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5853 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5854 // 65
5855 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5856 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5857 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5858 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5859 // 69
5860 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5861 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5862 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5863 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5864 // 73
5865 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5866 };
5867
5868 /*
5869 int32_t midi_dp[3] = {0,147,104};
5870 int32_t digi_dp[3] = {1,147,120};
5871 int32_t pan_dp[3] = {0,147,136};
5872 int32_t buf_dp[3] = {0,147,152};
5873 */
5874 int32_t midi_dp[3] = {0,0,0};
5875 int32_t digi_dp[3] = {1,0,0};
5876 int32_t emus_dp[3] = {2,0,0};
5877 int32_t buf_dp[3] = {0,0,0};
5878 int32_t sfx_dp[3] = {3,0,0};
5879 int32_t pan_dp[3] = {0,0,0};
5880
5881 static DIALOG sound_dlg[] =
5882 {
5883 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5884 115 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5885 115 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5886 115 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5887 115 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5888 115 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5889 115 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5890 115 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5891 115 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5892 115 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5893 115 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5894 // 10
5895 115 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5896 115 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5897 115 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5898 115 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5899 115 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5900 115 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5901 115 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5902 115 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5903 115 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5904 115 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5905 //20
5906 115 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5907 115 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5908 115 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5909 115 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5910 115 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5911 115 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5912 115 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5913 115 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5914 115 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5915 115 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5916 //30
5917 115 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5918 115 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5919 115 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5920 115 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5921 };
5922
5923 char zc_builddate[80];
5924 char zc_aboutstr[80];
5925
5926 static DIALOG about_dlg[] =
5927 {
5928 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5929 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5930 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5931 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5932 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5933 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5934 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5935 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5936 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5937 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5938 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5939 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5940 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5941 };
5942
5943
5944 static DIALOG quest_dlg[] =
5945 {
5946 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5947 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5948 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5949 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5950 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5951 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5952 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5953 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5954 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5955 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5956 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5957 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5958 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5959 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5960 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5961 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5962 };
5963
5964 static DIALOG triforce_dlg[] =
5965 {
5966 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5967 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5968 // 1
5969 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5970 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5971 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5972 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5973 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5974 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5975 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5976 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5977 // 9
5978 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5979 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5980 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5981 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5982 };
5983
5984 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5985 {
5986 go();
5987 int32_t ret=0;
5988 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5989 comeback();
5990 return ret != 0;
5991 }
5992
5993
5994 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5995 {
5996 if(def!=modulepath)
5997 strcpy(modulepath,def);
5998
5999 if(!usefilename)
6000 {
6001 int32_t i=(int32_t)strlen(modulepath);
6002
6003 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6004 modulepath[i--]=0;
6005 }
6006
6007 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6008 int32_t ret=0;
6009 int32_t sel=0;
6010
6011 if(list==NULL)
6012 {
6013 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
6014 }
6015 else
6016 {
6017 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
6018 }
6019
6020 return ret!=0;
6021 }
6022
6023 int32_t onToggleRecordingNewSaves()
6024 {
6025 if (zc_get_config("zeldadx", "replay_new_saves", false))
6026 {
6027 zc_set_config("zeldadx", "replay_new_saves", false);
6028 }
6029 else
6030 {
6031 zc_set_config("zeldadx", "replay_new_saves", true);
6032 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6033 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6034 }
6035 return D_O_K;
6036 }
6037
6038 int32_t onToggleSnapshotAllFrames()
6039 {
6040 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6041 return D_O_K;
6042 }
6043
6044 int32_t onStopReplayOrRecord()
6045 {
6046 if (replay_is_replaying())
6047 {
6048 replay_quit();
6049 }
6050 else if (replay_get_mode() == ReplayMode::Record)
6051 {
6052 if (!replay_get_meta_bool("test_mode"))
6053 {
6054 jwin_alert("Recording", "You cannot stop recording a save file.",
6055 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6056 return D_CLOSE;
6057 }
6058
6059 if (jwin_alert("Stop Recording",
6060 "Save replay to disk and stop recording?",
6061 "This will stop the recording.",
6062 NULL,
6063 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6064 return D_CLOSE;
6065
6066 replay_save();
6067 replay_stop();
6068 }
6069 return D_O_K;
6070 }
6071
6072 static int32_t handle_on_load_replay(ReplayMode mode)
6073 {
6074 if (Playing)
6075 {
6076 if (jwin_alert("Replay - Warning!",
6077 "Loading a replay will exit the current game.",
6078 "All unsaved progress will be lost.",
6079 "Do you wish to continue?",
6080 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6081 return D_CLOSE;
6082 }
6083
6084 std::string mode_string = replay_mode_to_string(mode);
6085 mode_string[0] = std::toupper(mode_string[0]);
6086
6087 std::string line_1 = "Select a replay file to play back.";
6088 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6089 std::string line_3 = "You can stop the replay and take over manually any time.";
6090 if (mode == ReplayMode::Update)
6091 {
6092 line_1 = "Select a replay file to update.";
6093 line_2 = "WARNING: be sure to back up the zplay file";
6094 line_3 = "and verify that the updated replay works as expected!";
6095 }
6096
6097 if (jwin_alert(mode_string.c_str(),
6098 line_1.c_str(),
6099 line_2.c_str(),
6100 line_3.c_str(),
6101 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6102 {
6103 char replay_path[2048];
6104 strcpy(replay_path, "replays/");
6105 if (jwin_file_select_ex(
6106 fmt::format("Load Replay ({})", REPLAY_EXTENSION).c_str(),
6107 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6108 return D_CLOSE;
6109
6110 replay_quit();
6111 load_replay_file_deferred(mode, replay_path);
6112 Quit = qRESET;
6113 return D_CLOSE;
6114 }
6115 return D_O_K;
6116 }
6117
6118 int32_t onLoadReplay()
6119 {
6120 return handle_on_load_replay(ReplayMode::Replay);
6121 }
6122
6123 int32_t onLoadReplayAssert()
6124 {
6125 return handle_on_load_replay(ReplayMode::Assert);
6126 }
6127
6128 int32_t onLoadReplayUpdate()
6129 {
6130 return handle_on_load_replay(ReplayMode::Update);
6131 }
6132
6133 int32_t onSaveReplay()
6134 {
6135 if (replay_get_mode() == ReplayMode::Record)
6136 {
6137 if (!replay_get_meta_bool("test_mode"))
6138 {
6139 if (jwin_alert("Save Replay",
6140 "This will save a copy of the replay up to this point.",
6141 "The official replay file will be untouched.",
6142 "Do you wish to continue?",
6143 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6144 return D_CLOSE;
6145
6146 char replay_path[2048];
6147 strcpy(replay_path, replay_get_replay_path().string().c_str());
6148 if (jwin_file_select_ex(
6149 fmt::format("Save Replay ({})", REPLAY_EXTENSION).c_str(),
6150 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6151 return D_CLOSE;
6152
6153 if (fileexists(replay_path))
6154 {
6155 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6156 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6157 return D_CLOSE;
6158 }
6159
6160 replay_save(replay_path);
6161 }
6162 else
6163 {
6164 replay_save();
6165 }
6166 }
6167 return D_O_K;
6168 }
6169
6170 static MENU replay_menu[] =
6171 {
6172 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6173 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6174 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6175 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6176 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6177 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6178 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6179
6180 { NULL, NULL, NULL, 0, NULL }
6181 };
6182
6183 static DIALOG credits_dlg[] =
6184 {
6185 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6186 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "ZQuest Classic Credits", NULL, NULL },
6187 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6188 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6189 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6190 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6191 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6192 };
6193
6194 115 static ListData dmap_list(dmaplist, &font);
6195
6196 static DIALOG goto_dlg[] =
6197 {
6198 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6199 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6200 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6201 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6202 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6203 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6204 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6205 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6206 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6207 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6208 };
6209
6210 int32_t onGoTo()
6211 {
6212 bool music = false;
6213 music = music;
6214 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6215
6216 goto_dlg[0].dp2=get_zc_font(font_lfont);
6217 goto_dlg[4].d2=cheat_goto_dmap;
6218 goto_dlg[6].dp=cheat_goto_screen_str;
6219
6220 clear_keybuf();
6221
6222 large_dialog(goto_dlg);
6223
6224 if(do_zqdialog(goto_dlg,4)==1)
6225 {
6226 // dmap, screen
6227 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6228 };
6229
6230 return D_O_K;
6231 }
6232
6233 int32_t onGoToComplete()
6234 {
6235 if(!Playing)
6236 {
6237 return D_O_K;
6238 }
6239
6240 enter_sys_pal();
6241 music_pause();
6242 pause_all_sfx();
6243 onGoTo();
6244 eat_buttons();
6245
6246 zc_readrawkey(KEY_ESC);
6247
6248 exit_sys_pal();
6249 music_resume();
6250 resume_all_sfx();
6251 return D_O_K;
6252 }
6253
6254 int32_t onCredits()
6255 {
6256 return D_O_K;
6257 }
6258
6259 const char *midilist(int32_t index, int32_t *list_size)
6260 {
6261 if(index<0)
6262 {
6263 *list_size=0;
6264
6265 for(int32_t i=0; i<MAXMIDIS; i++)
6266 if(tunes[i].data)
6267 ++(*list_size);
6268
6269 return NULL;
6270 }
6271
6272 int32_t i=0,m=0;
6273
6274 while(m<=index && i<=MAXMIDIS)
6275 {
6276 if(tunes[i].data)
6277 ++m;
6278
6279 ++i;
6280 }
6281
6282 --i;
6283
6284 if(i==MAXMIDIS && m<index)
6285 return "(null)";
6286
6287 return tunes[i].title;
6288 }
6289
6290 /* ------- MIDI info stuff -------- */
6291
6292 char *text;
6293 midi_info *zmi;
6294 bool dialog_running;
6295 bool listening;
6296
6297 void get_info(int32_t index);
6298
6299 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6300 {
6301 int32_t d2 = d->d2;
6302 int32_t ret = jwin_droplist_proc(msg,d,c);
6303
6304 if(d2!=d->d2)
6305 {
6306 get_info(d->d2);
6307 }
6308
6309 return ret;
6310 }
6311
6312 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6313 {
6314 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6315
6316 int32_t ret = jwin_button_proc(msg,d,c);
6317
6318 if(ret == D_CLOSE)
6319 {
6320 // get current midi index
6321 int32_t index = (d+(d->d1))->d2;
6322 int32_t i=0, m=0;
6323
6324 while(m<=index && i<=MAXMIDIS)
6325 {
6326 if(tunes[i].data)
6327 ++m;
6328
6329 ++i;
6330 }
6331
6332 --i;
6333 jukebox(i);
6334 listening = true;
6335 ret = D_O_K;
6336 }
6337
6338 return ret;
6339 }
6340
6341 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6342 {
6343 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6344
6345 int32_t ret = jwin_button_proc(msg,d,c);
6346
6347 if(ret == D_CLOSE)
6348 {
6349 // get current midi index
6350 int32_t index = (d+(d->d1))->d2;
6351 int32_t i=0, m=0;
6352
6353 while(m<=index && i<=MAXMIDIS)
6354 {
6355 if(tunes[i].data)
6356 ++m;
6357
6358 ++i;
6359 }
6360
6361 --i;
6362
6363 // get file name
6364
6365 int32_t sel=0;
6366 //struct ffblk f;
6367 char title[40] = "Save MIDI: ";
6368 char fname[2048];
6369 memset(fname,0,2048);
6370 static EXT_LIST list[] =
6371 {
6372 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6373 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6374 { NULL, NULL }
6375 };
6376
6377 strcpy(title+11, tunes[i].title);
6378 title[39] = '\0';
6379
6380 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6381 goto done;
6382
6383 if(exists(fname))
6384 {
6385 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6386 goto done;
6387 }
6388
6389 // save midi i
6390
6391 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6392 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6393
6394 done:
6395 chop_path(fname);
6396 ret = D_REDRAW;
6397 }
6398
6399 return ret;
6400 }
6401
6402 115 static ListData midi_list(midilist, &font);
6403
6404 static DIALOG midi_dlg[] =
6405 {
6406 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6407 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6408 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6409 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6410 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6411 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6412 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6413 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6414 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6415 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6416 };
6417
6418 void get_info(int32_t index)
6419 {
6420 int32_t i=0, m=0;
6421
6422 while(m<=index && i<=MAXMIDIS)
6423 {
6424 if(tunes[i].data)
6425 ++m;
6426
6427 ++i;
6428 }
6429
6430 --i;
6431
6432 if(i==MAXMIDIS && m<index)
6433 strcpy(text,"(null)");
6434 else
6435 {
6436 get_midi_info((MIDI*)tunes[i].data,zmi);
6437 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6438 }
6439
6440 midi_dlg[0].dp2=get_zc_font(font_lfont);
6441 midi_dlg[3].dp = text;
6442 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6443 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6444
6445 if(dialog_running)
6446 {
6447 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6448 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6449 }
6450 }
6451
6452 int32_t onMIDICredits()
6453 {
6454 text = (char*)malloc(4096);
6455 zmi = (midi_info*)malloc(sizeof(midi_info));
6456
6457 if(!text || !zmi)
6458 {
6459 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6460 return D_O_K;
6461 }
6462
6463 bool do_pause_midi = midi_pos >= 0 && currmidi;
6464 auto restore_midi = currmidi;
6465 if(do_pause_midi)
6466 {
6467 paused_midi_pos = midi_pos;
6468 stop_midi();
6469 midi_suspended = midissuspHALTED;
6470 }
6471
6472 midi_dlg[0].dp2=get_zc_font(font_lfont);
6473 midi_dlg[2].d1 = 0;
6474 midi_dlg[2].d2 = 0;
6475 midi_dlg[4].flags = D_EXIT;
6476 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6477
6478 listening = false;
6479 dialog_running=false;
6480 get_info(0);
6481
6482 dialog_running=true;
6483
6484 large_dialog(midi_dlg);
6485
6486 do_zqdialog(midi_dlg,0);
6487 dialog_running=false;
6488
6489 if(listening)
6490 music_stop();
6491
6492 if(do_pause_midi)
6493 {
6494 // TODO: this probably doesn't resume midis nicely when scrolling (or in some other inner-gameloop).
6495 midi_suspended = midissuspRESUME;
6496 currmidi = restore_midi;
6497 midi_pos = paused_midi_pos;
6498 }
6499
6500 if(text) free(text);
6501 if(zmi) free(zmi);
6502 return D_O_K;
6503 }
6504
6505 int32_t onAbout()
6506 {
6507 char buf1[80]={0};
6508 std::ostringstream oss;
6509 sprintf(buf1,"%s, Version: %s", ZC_PLAYER_NAME,ZC_PLAYER_V);
6510 oss << buf1 << '\n';
6511 sprintf(buf1, "%s", ALPHA_VER_STR);
6512 oss << buf1 << '\n';
6513 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6514 oss << buf1 << '\n';
6515 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6516 oss << buf1 << '\n';
6517 sprintf(buf1, "Tag: %s", getReleaseTag());
6518 oss << buf1 << '\n';
6519
6520 InfoDialog("About ZC", oss.str()).show();
6521 return D_O_K;
6522 }
6523
6524 int32_t onQuest()
6525 {
6526 char fname[100];
6527 strcpy(fname, get_filename(qstpath));
6528 quest_dlg[0].dp2=get_zc_font(font_lfont);
6529 quest_dlg[1].dp = fname;
6530
6531 if(QHeader.quest_number==0)
6532 sprintf(str_a,"Custom");
6533 else
6534 sprintf(str_a,"%d",QHeader.quest_number);
6535
6536 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6537
6538 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6539 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6540
6541 large_dialog(quest_dlg);
6542
6543 do_zqdialog(quest_dlg, 0);
6544 return D_O_K;
6545 }
6546
6547 void call_vidmode_dlg();
6548 int32_t onVidMode()
6549 {
6550 call_vidmode_dlg();
6551 return D_O_K;
6552 }
6553
6554 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6555 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6556 //Added an extra statement, so that if the key is cleared to 0, the cleared
6557 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6558
6559 void load_ukeys(int32_t* arr)
6560 {
6561 arr[ukey_a] = Akey;
6562 arr[ukey_b] = Bkey;
6563 arr[ukey_s] = Skey;
6564 arr[ukey_l] = Lkey;
6565 arr[ukey_r] = Rkey;
6566 arr[ukey_p] = Pkey;
6567 arr[ukey_ex1] = Exkey1;
6568 arr[ukey_ex2] = Exkey2;
6569 arr[ukey_ex3] = Exkey3;
6570 arr[ukey_ex4] = Exkey4;
6571 arr[ukey_du] = DUkey;
6572 arr[ukey_dd] = DDkey;
6573 arr[ukey_dl] = DLkey;
6574 arr[ukey_dr] = DRkey;
6575 arr[ukey_mod1a] = cheat_modifier_keys[0];
6576 arr[ukey_mod1b] = cheat_modifier_keys[1];
6577 arr[ukey_mod2a] = cheat_modifier_keys[2];
6578 arr[ukey_mod2b] = cheat_modifier_keys[3];
6579 };
6580
6581 static const char* ukey_names[] = {
6582 "A", "B", "Start", "L", "R", "Map",
6583 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6584 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6585 "Cheat Mod R1", "Cheat Mod R2",
6586 };
6587 std::string get_ukey_name(int32_t k)
6588 {
6589 if (k < num_ukey) return ukey_names[k];
6590 return "";
6591 }
6592
6593 int32_t onKeyboard()
6594 {
6595 int32_t a = Akey;
6596 int32_t b = Bkey;
6597 int32_t s = Skey;
6598 int32_t l = Lkey;
6599 int32_t r = Rkey;
6600 int32_t p = Pkey;
6601 int32_t ex1 = Exkey1;
6602 int32_t ex2 = Exkey2;
6603 int32_t ex3 = Exkey3;
6604 int32_t ex4 = Exkey4;
6605 int32_t du = DUkey;
6606 int32_t dd = DDkey;
6607 int32_t dl = DLkey;
6608 int32_t dr = DRkey;
6609 int32_t mod1a = cheat_modifier_keys[0];
6610 int32_t mod1b = cheat_modifier_keys[1];
6611 int32_t mod2a = cheat_modifier_keys[2];
6612 int32_t mod2b = cheat_modifier_keys[3];
6613 bool done=false;
6614 int32_t ret;
6615
6616 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6617
6618 large_dialog(keyboard_control_dlg);
6619
6620 while(!done)
6621 {
6622 ret = do_zqdialog(keyboard_control_dlg,3);
6623
6624 if(ret==3) // OK
6625 {
6626 int32_t ukeys[num_ukey];
6627 load_ukeys(ukeys);
6628 std::vector<std::string> uniqueError;
6629 for(int32_t q = 0; q < num_ukey; ++q)
6630 {
6631 for(int32_t p = q+1; p < num_ukey; ++p)
6632 {
6633 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6634 {
6635 char buf[64];
6636 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6637 std::string str(buf);
6638 uniqueError.push_back(str);
6639 }
6640 }
6641 }
6642 if(uniqueError.size() == 0)
6643 {
6644 done = true;
6645 save_control_configs(true);
6646 }
6647 else
6648 {
6649 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6650 box_out("Cannot have duplicate keybinds!"); box_eol();
6651 for(std::vector<std::string>::iterator it = uniqueError.begin();
6652 it != uniqueError.end(); ++it)
6653 {
6654 box_out((*it).c_str()); box_eol();
6655 }
6656 box_end(true);
6657 }
6658 }
6659 else // Cancel
6660 {
6661 Akey = a;
6662 Bkey = b;
6663 Skey = s;
6664 Lkey = l;
6665 Rkey = r;
6666 Pkey = p;
6667 Exkey1 = ex1;
6668 Exkey2 = ex2;
6669 Exkey3 = ex3;
6670 Exkey4 = ex4;
6671 DUkey = du;
6672 DDkey = dd;
6673 DLkey = dl;
6674 DRkey = dr;
6675 cheat_modifier_keys[0] = mod1a;
6676 cheat_modifier_keys[1] = mod1b;
6677 cheat_modifier_keys[2] = mod2a;
6678 cheat_modifier_keys[3] = mod2b;
6679
6680 done=true;
6681 }
6682
6683 rest(1);
6684 }
6685
6686 return D_O_K;
6687 }
6688
6689 int32_t onGamepad()
6690 {
6691 int32_t a = Abtn;
6692 int32_t b = Bbtn;
6693 int32_t s = Sbtn;
6694 int32_t l = Lbtn;
6695 int32_t r = Rbtn;
6696 int32_t m = Mbtn;
6697 int32_t p = Pbtn;
6698 int32_t ex1 = Exbtn1;
6699 int32_t ex2 = Exbtn2;
6700 int32_t ex3 = Exbtn3;
6701 int32_t ex4 = Exbtn4;
6702 int32_t up = DUbtn;
6703 int32_t down = DDbtn;
6704 int32_t left = DLbtn;
6705 int32_t right = DRbtn;
6706 int32_t joy = joystick_index;
6707 int32_t stick_1 = js_stick_1_x_stick;
6708 int32_t stick_2 = js_stick_2_x_stick;
6709
6710 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6711 if(analog_movement)
6712 gamepad_dlg[56].flags|=D_SELECTED;
6713 else
6714 gamepad_dlg[56].flags&=~D_SELECTED;
6715
6716 // TODO: should use controller device GUID or name instead of index, otherwise this value is not
6717 // consistent unless exact same number of joysticks is always connected. Name is problematic b/c
6718 // xinput driver doesn't actually get a name (at least, doesn't for my Xbox controller).
6719 // TODO: should store gamepad control mappings per-controller, otherwise switching joystick
6720 // requires remapping every time.
6721 if (joystick_index >= al_get_num_joysticks())
6722 joystick_index = 0;
6723 gamepad_dlg[61].d2 = joystick_index;
6724
6725 large_dialog(gamepad_dlg);
6726
6727 int32_t ret = do_zqdialog(gamepad_dlg,4);
6728
6729 if(ret == 4) //OK
6730 {
6731 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6732 joystick_index = gamepad_dlg[61].d2;
6733 js_stick_1_y_stick = js_stick_1_x_stick;
6734 js_stick_2_y_stick = js_stick_2_x_stick;
6735 save_control_configs(false);
6736 }
6737 else //Cancel
6738 {
6739 Abtn = a;
6740 Bbtn = b;
6741 Sbtn = s;
6742 Lbtn = l;
6743 Rbtn = r;
6744 Mbtn = m;
6745 Pbtn = p;
6746 Exbtn1 = ex1;
6747 Exbtn2 = ex2;
6748 Exbtn3 = ex3;
6749 Exbtn4 = ex4;
6750 DUbtn = up;
6751 DDbtn = down;
6752 DLbtn = left;
6753 DRbtn = right;
6754 joystick_index = joy;
6755 js_stick_1_x_stick = stick_1;
6756 js_stick_2_x_stick = stick_2;
6757 }
6758
6759 return D_O_K;
6760 }
6761
6762 int32_t onCheatKeys()
6763 {
6764 int32_t oldcheats[Cheat::Last][2];
6765 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6766
6767 bool done=false;
6768
6769 while(!done)
6770 {
6771 bool confirm = false;
6772 CheatKeysDialog(&confirm).show();
6773 if(confirm) // OK
6774 {
6775 std::vector<std::string> uniqueError;
6776 char buf[512];
6777 for(size_t q = 1; q < Cheat::Last; ++q)
6778 {
6779 if(cheatkeys[q][1] && !cheatkeys[q][0])
6780 {
6781 cheatkeys[q][0] = cheatkeys[q][1];
6782 cheatkeys[q][1] = 0;
6783 }
6784 }
6785 for(size_t q = 1; q < Cheat::Last; ++q)
6786 {
6787 if(!bindable_cheat((Cheat)q)) continue;
6788 for(size_t p = q+1; p < Cheat::Last; ++p)
6789 {
6790 if(!bindable_cheat((Cheat)p)) continue;
6791 for(size_t q2 = 0; q2 <= 1; ++q2)
6792 for(size_t p2 = 0; p2 <= 1; ++p2)
6793 {
6794 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6795 {
6796 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6797 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6798 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6799 get_keystr(cheatkeys[q][q2])));
6800 }
6801 }
6802 }
6803 }
6804 if(uniqueError.size() == 0)
6805 {
6806 done = true;
6807 save_cheatkeys();
6808 }
6809 else
6810 {
6811 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
6812 box_out("Cannot have duplicate keybinds!"); box_eol();
6813 for(std::vector<std::string>::iterator it = uniqueError.begin();
6814 it != uniqueError.end(); ++it)
6815 {
6816 box_out((*it).c_str()); box_eol();
6817 }
6818 box_end(true);
6819 }
6820 }
6821 else // Cancel
6822 {
6823 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6824 done=true;
6825 }
6826 rest(1);
6827 }
6828
6829 return D_O_K;
6830 }
6831
6832 int32_t onSound()
6833 {
6834 if (get_qr(qr_OLD_SCRIPT_VOLUME))
6835 {
6836 if (FFCore.coreflags & FFCORE_SCRIPTED_MIDI_VOLUME)
6837 {
6838 master_volume(-1, ((int32_t)FFCore.usr_midi_volume));
6839 }
6840 if (FFCore.coreflags & FFCORE_SCRIPTED_DIGI_VOLUME)
6841 {
6842 master_volume((int32_t)(FFCore.usr_digi_volume), 1);
6843 }
6844 if (FFCore.coreflags & FFCORE_SCRIPTED_MUSIC_VOLUME)
6845 {
6846 emusic_volume = (int32_t)FFCore.usr_music_volume;
6847 }
6848 if (FFCore.coreflags & FFCORE_SCRIPTED_SFX_VOLUME)
6849 {
6850 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
6851 }
6852 }
6853 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
6854 {
6855 pan_style = (int32_t)FFCore.usr_panstyle;
6856 }
6857
6858 int32_t m = midi_volume;
6859 int32_t d = digi_volume;
6860 int32_t e = emusic_volume;
6861 int32_t b = zcmusic_bufsz;
6862 int32_t s = sfx_volume;
6863 int32_t p = pan_style;
6864 pan_style = vbound(pan_style,0,3);
6865
6866 sound_dlg[0].dp2=get_zc_font(font_lfont);
6867
6868 large_dialog(sound_dlg);
6869
6870 midi_dp[1] = sound_dlg[6].x;
6871 midi_dp[2] = sound_dlg[6].y;
6872 digi_dp[1] = sound_dlg[7].x;
6873 digi_dp[2] = sound_dlg[7].y;
6874 emus_dp[1] = sound_dlg[8].x;
6875 emus_dp[2] = sound_dlg[8].y;
6876 buf_dp[1] = sound_dlg[9].x;
6877 buf_dp[2] = sound_dlg[9].y;
6878 sfx_dp[1] = sound_dlg[10].x;
6879 sfx_dp[2] = sound_dlg[10].y;
6880 pan_dp[1] = sound_dlg[11].x;
6881 pan_dp[2] = sound_dlg[11].y;
6882 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
6883 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
6884 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
6885 sound_dlg[18].d2 = zcmusic_bufsz;
6886 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
6887 sound_dlg[20].d2 = pan_style;
6888
6889 int32_t ret = do_zqdialog(sound_dlg,1);
6890
6891 if(ret==2)
6892 {
6893 master_volume(digi_volume,midi_volume);
6894 if (zcmusic)
6895 zcmusic_set_volume(zcmusic, emusic_volume);
6896
6897 int32_t temp_volume = sfx_volume;
6898 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
6899 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
6900 for(int32_t i=0; i<WAV_COUNT; ++i)
6901 {
6902 //allegro assertion fails when passing in -1 as voice -DD
6903 if(sfx_voice[i] > 0)
6904 voice_set_volume(sfx_voice[i], temp_volume);
6905 }
6906 zc_set_config(sfx_sect,"digi",digi_volume);
6907 zc_set_config(sfx_sect,"midi",midi_volume);
6908 zc_set_config(sfx_sect,"sfx",sfx_volume);
6909 zc_set_config(sfx_sect,"emusic",emusic_volume);
6910 zc_set_config(sfx_sect,"pan",pan_style);
6911 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
6912 }
6913 else
6914 {
6915 midi_volume = m;
6916 digi_volume = d;
6917 emusic_volume = e;
6918 zcmusic_bufsz = b;
6919 sfx_volume = s;
6920 pan_style = p;
6921 }
6922
6923 return D_O_K;
6924 }
6925
6926 int32_t queding(char const* s1, char const* s2, char const* s3)
6927 {
6928 return jwin_alert("ZQuest Classic",s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
6929 }
6930
6931 int32_t onQuit()
6932 {
6933 if(Playing)
6934 {
6935 int32_t ret=0;
6936
6937 if(get_qr(qr_NOCONTINUE))
6938 {
6939 if(standalone_mode)
6940 {
6941 ret=queding("End current game?",
6942 "The continue screen is disabled; the game",
6943 "will be reloaded from the last save.");
6944 }
6945 else
6946 {
6947 ret=queding("End current game?",
6948 "The continue screen is disabled. You will",
6949 "be returned to the file select screen.");
6950 }
6951 }
6952 else
6953 ret=queding("End current game?",NULL,NULL);
6954
6955 if(ret==1)
6956 {
6957 disableClickToFreeze=false;
6958 Quit=qQUIT;
6959
6960 // Trying to evade a door repair charge?
6961 if(repaircharge)
6962 {
6963 game->change_drupy(-repaircharge);
6964 repaircharge=0;
6965 }
6966
6967 return D_CLOSE;
6968 }
6969 }
6970
6971 return D_O_K;
6972 }
6973
6974 int32_t onTryQuitMenu()
6975 {
6976 return onTryQuit(true);
6977 }
6978
6979 int32_t onTryQuit(bool inMenu)
6980 {
6981 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
6982 {
6983 if(active_cutscene.can_f6())
6984 {
6985 if(get_qr(qr_OLD_F6))
6986 {
6987 if(inMenu) onQuit();
6988 else /*if(!get_qr(qr_NOCONTINUE))*/ f_Quit(qQUIT);
6989 }
6990 else
6991 {
6992 disableClickToFreeze=false;
6993 GameFlags |= GAMEFLAG_TRYQUIT;
6994 }
6995 return D_CLOSE;
6996 }
6997 else active_cutscene.error();
6998 }
6999
7000 return D_O_K;
7001 }
7002
7003 int32_t onReset()
7004 {
7005 if(queding(" Reset system? ",NULL,NULL)==1)
7006 {
7007 disableClickToFreeze=false;
7008 Quit=qRESET;
7009 replay_quit();
7010 return D_CLOSE;
7011 }
7012
7013 return D_O_K;
7014 }
7015
7016 int32_t onExit()
7017 {
7018 if(queding(" Quit ZQuest Classic? ",NULL,NULL)==1)
7019 {
7020 Quit=qEXIT;
7021 return D_CLOSE;
7022 }
7023
7024 return D_O_K;
7025 }
7026
7027 int32_t onDebug()
7028 {
7029 if(debug_enabled)
7030 set_debug(!get_debug());
7031 return D_O_K;
7032 }
7033
7034 int32_t onHeartBeep()
7035 {
7036 heart_beep=!heart_beep;
7037 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7038 return D_O_K;
7039 }
7040
7041 int32_t onSaveIndicator()
7042 {
7043 use_save_indicator = use_save_indicator ? 0 : 1;
7044 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7045 return D_O_K;
7046 }
7047
7048 int32_t onEpilepsy()
7049 {
7050 if(jwin_alert3(
7051 "Epilepsy Flash Reduction",
7052 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7053 "Disabling this will restore standard flash and wavy behaviour.",
7054 "Proceed?",
7055 "&Yes",
7056 "&No",
7057 NULL,
7058 'y',
7059 'n',
7060 0,
7061 get_zc_font(font_lfont)) == 1)
7062 {
7063 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7064 zc_set_config("zeldadx","checked_epilepsy",1);
7065 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7066 }
7067 return D_O_K;
7068 }
7069
7070 int32_t onTriforce()
7071 {
7072 for(int32_t i=0; i<MAXINITTABS; ++i)
7073 {
7074 init_tabs[i].flags&=~D_SELECTED;
7075 }
7076
7077 init_tabs[3].flags=D_SELECTED;
7078 return onCheatConsole();
7079 /*triforce_dlg[0].dp2=get_zc_font(font_lfont);
7080 for(int32_t i=1; i<=8; i++)
7081 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7082
7083 if(do_zqdialog (triforce_dlg,-1)==9)
7084 {
7085 for(int32_t i=1; i<=8; i++)
7086 {
7087 game->lvlitems[i] &= ~liTRIFORCE;
7088 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7089 }
7090 }
7091 return D_O_K;*/
7092 }
7093
7094 bool rc = false;
7095 /*
7096 int32_t onEquipment()
7097 {
7098 for (int32_t i=0; i<MAXINITTABS; ++i)
7099 {
7100 init_tabs[i].flags&=~D_SELECTED;
7101 }
7102 init_tabs[0].flags=D_SELECTED;
7103 return onCheatConsole();
7104 }
7105 */
7106
7107 int32_t onItems()
7108 {
7109 for(int32_t i=0; i<MAXINITTABS; ++i)
7110 {
7111 init_tabs[i].flags&=~D_SELECTED;
7112 }
7113
7114 init_tabs[1].flags=D_SELECTED;
7115 return onCheatConsole();
7116 }
7117
7118 static DIALOG getnum_dlg[] =
7119 {
7120 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7121 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7122 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7123 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7124 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7125 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7126 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7127 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7128 };
7129
7130 int32_t getnumber(const char *prompt,int32_t initialval)
7131 {
7132 char buf[20];
7133 sprintf(buf,"%d",initialval);
7134 getnum_dlg[0].dp=(void *)prompt;
7135 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7136 getnum_dlg[2].dp=buf;
7137
7138 large_dialog(getnum_dlg);
7139
7140 if(do_zqdialog(getnum_dlg,2)==3)
7141 return atoi(buf);
7142
7143 return initialval;
7144 }
7145
7146 int32_t onLife()
7147 {
7148 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7149 cheats_enqueue(Cheat::Life, value);
7150 return D_O_K;
7151 }
7152
7153 int32_t onHeartC()
7154 {
7155 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7156 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7157 cheats_enqueue(Cheat::MaxLife, max_life);
7158 cheats_enqueue(Cheat::Life, life);
7159 return D_O_K;
7160 }
7161
7162 int32_t onMagicC()
7163 {
7164 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7165 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,max_magic/game->get_mp_per_block())*game->get_mp_per_block();
7166 cheats_enqueue(Cheat::MaxMagic, max_magic);
7167 cheats_enqueue(Cheat::Magic, magic);
7168 return D_O_K;
7169 }
7170
7171 int32_t onRupies()
7172 {
7173 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7174 cheats_enqueue(Cheat::Rupies, value);
7175 return D_O_K;
7176 }
7177
7178 int32_t onMaxBombs()
7179 {
7180 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7181 cheats_enqueue(Cheat::MaxBombs, value);
7182 cheats_enqueue(Cheat::Bombs, value);
7183 return D_O_K;
7184 }
7185
7186 int32_t onRefillLife()
7187 {
7188 cheats_enqueue(Cheat::Life, game->get_maxlife());
7189 return D_O_K;
7190 }
7191 int32_t onRefillMagic()
7192 {
7193 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7194 return D_O_K;
7195 }
7196 int32_t onClock()
7197 {
7198 cheats_enqueue(Cheat::Clock);
7199 return D_O_K;
7200 }
7201
7202 int32_t onQstPath()
7203 {
7204 char path[2048];
7205
7206 chop_path(qstdir);
7207 strcpy(path,qstdir);
7208
7209 go();
7210
7211 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7212 {
7213 chop_path(path);
7214 fix_filename_case(path);
7215 fix_filename_slashes(path);
7216 strcpy(qstdir,path);
7217 strcpy(qstpath,qstdir);
7218 }
7219
7220 comeback();
7221 return D_O_K;
7222 }
7223
7224 #include "dialog/cheat_dialog.h"
7225 int32_t onCheat()
7226 {
7227 call_setcheat_dialog();
7228 game->set_cheat(maxcheat);
7229 if(cheat) game->did_cheat(true);
7230 return D_O_K;
7231 }
7232
7233 int32_t onCheatRupies()
7234 {
7235 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7236 return D_O_K;
7237 }
7238
7239 int32_t onCheatArrows()
7240 {
7241 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7242 return D_O_K;
7243 }
7244
7245 int32_t onCheatBombs()
7246 {
7247 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7248 return D_O_K;
7249 }
7250
7251 // *** screen saver
7252
7253 9285637 int32_t after_time()
7254 {
7255
1/2
✓ Branch 0 taken 9285637 times.
✗ Branch 1 not taken.
9285637 if(ss_enable == 0)
7256 return INT_MAX;
7257
7258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9285637 times.
9285637 if(ss_after <= 0)
7259 return 5 * 60;
7260
7261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9285637 times.
9285637 if(ss_after <= 3)
7262 return ss_after * 15 * 60;
7263
7264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9285637 times.
9285637 if(ss_after <= 13)
7265 return (ss_after - 3) * 60 * 60;
7266
7267 9285637 return MAX_IDLE + 1;
7268 9285637 }
7269
7270 static const char *after_str[15] =
7271 {
7272 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7273 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7274 "Never"
7275 };
7276
7277 const char *after_list(int32_t index, int32_t *list_size)
7278 {
7279 if(index < 0)
7280 {
7281 *list_size = 15;
7282 return NULL;
7283 }
7284
7285 return after_str[index];
7286 }
7287
7288 115 static ListData after__list(after_list, &font);
7289
7290 static DIALOG scrsaver_dlg[] =
7291 {
7292 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7293 115 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7294 115 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7295 115 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7296 115 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7297 115 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7298 115 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7299 115 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7300 115 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7301 115 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7302 115 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7303 115 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7304 115 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7305 115 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7306 };
7307
7308 int32_t onScreenSaver()
7309 {
7310 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7311 int32_t oldcfgs[3];
7312 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7313 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7314 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7315
7316 large_dialog(scrsaver_dlg);
7317
7318 int32_t ret = do_zqdialog(scrsaver_dlg,-1);
7319
7320 if(ret == 8 || ret == 9)
7321 {
7322 ss_after = scrsaver_dlg[5].d1;
7323 ss_speed = scrsaver_dlg[6].d2;
7324 ss_density = scrsaver_dlg[7].d2;
7325 if(oldcfgs[0] != ss_after)
7326 zc_set_config(cfg_sect,"ss_after",ss_after);
7327 if(oldcfgs[1] != ss_speed)
7328 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7329 if(oldcfgs[2] != ss_density)
7330 zc_set_config(cfg_sect,"ss_density",ss_density);
7331 }
7332
7333 if(ret == 9)
7334 // preview Screen Saver
7335 {
7336 clear_keybuf();
7337 Matrix(ss_speed, ss_density, 30);
7338 system_pal(true);
7339 sys_mouse();
7340 }
7341
7342 return D_O_K;
7343 }
7344
7345 /***** Menus *****/
7346
7347 static MENU game_menu[] =
7348 {
7349 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7350 { (char *)"", NULL, NULL, 0, NULL },
7351 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7352 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7353 { (char *)"", NULL, NULL, 0, NULL },
7354 #ifdef __EMSCRIPTEN__
7355 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7356 #elif defined(ALLEGRO_MACOSX)
7357 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7358 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7359 #else
7360 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7361 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7362 #endif
7363 { NULL, NULL, NULL, 0, NULL }
7364 };
7365
7366 static MENU snapshot_format_menu[] =
7367 {
7368 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7369 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7370 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7371 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7372 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7373 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7374 { NULL, NULL, NULL, 0, NULL }
7375 };
7376
7377 static MENU controls_menu[] =
7378 {
7379 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7380 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7381 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7382 { NULL, NULL, NULL, 0, NULL }
7383 };
7384
7385 static MENU name_entry_mode_menu[] =
7386 {
7387 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7388 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7389 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7390 { NULL, NULL, NULL, 0, NULL }
7391 };
7392
7393 static void set_controls_menu_active()
7394 {
7395
7396 }
7397
7398 static MENU window_menu[] =
7399 {
7400 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7401 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7402 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7403 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7404 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7405 { NULL, NULL, NULL, 0, NULL }
7406 };
7407 static MENU options_menu[] =
7408 {
7409 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7410 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7411 { "&Window Settings", NULL, window_menu, 0, NULL },
7412 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7413 { "Pause In Background", onPauseInBackground, NULL, 0, NULL },
7414 { NULL, NULL, NULL, 0, NULL }
7415 };
7416 static MENU settings_menu[] =
7417 {
7418 { "&Sound...", onSound, NULL, 0, NULL },
7419 { "C&ontrols", NULL, controls_menu, 0, NULL },
7420 { "", NULL, NULL, 0, NULL },
7421 { "Options", NULL, options_menu, 0, NULL },
7422 { "", NULL, NULL, 0, NULL },
7423 //
7424 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7425 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7426 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7427 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7428 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7429 //
7430 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7431 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7432 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7433 { "", NULL, NULL, 0, NULL },
7434 { "Debu&g", onDebug, NULL, 0, NULL },
7435 //
7436 { NULL, NULL, NULL, 0, NULL }
7437 };
7438
7439
7440 static MENU misc_menu[] =
7441 {
7442 { (char *)"&About...", onAbout, NULL, 0, NULL },
7443 // TODO: re-enable, but: 1) do not use a bitmap thing that is hard to update 2) update names and 3) don't use the Z-word.
7444 { (char *)"&Credits...", onCredits, NULL, D_DISABLED, NULL },
7445 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7446 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7447 { (char *)"", NULL, NULL, 0, NULL },
7448 //5
7449 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7450 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7451 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7452 { (char *)"", NULL, NULL, 0, NULL },
7453 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7454 //10
7455 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7456 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7457 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7458 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7459 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7460 //15
7461 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7462 { NULL, NULL, NULL, 0, NULL }
7463 };
7464
7465 static MENU refill_menu[] =
7466 {
7467 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7468 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7469 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7470 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7471 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7472 { NULL, NULL, NULL, 0, NULL }
7473 };
7474
7475 static MENU show_menu[] =
7476 {
7477 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7478 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7479 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7480 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7481 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7482 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7483 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7484 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7485 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7486 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7487 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7488 { (char *)"", NULL, NULL, 0, NULL },
7489 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7490 { (char *)"", NULL, NULL, 0, NULL },
7491 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7492 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7493 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7494 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7495 { NULL, NULL, NULL, 0, NULL }
7496 };
7497
7498 static MENU cheat_menu[] =
7499 {
7500 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7501 { (char *)"", NULL, NULL, 0, NULL },
7502 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7503 { (char *)"", NULL, NULL, 0, NULL },
7504 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7505 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7506 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7507 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7508 { (char *)"", NULL, NULL, 0, NULL },
7509 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7510 { (char *)"", NULL, NULL, 0, NULL },
7511 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7512 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7513 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7514 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7515 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7516 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7517 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7518 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7519 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7520 { NULL, NULL, NULL, 0, NULL }
7521 };
7522
7523 #if DEVLEVEL > 0
7524 int32_t devLogging();
7525 int32_t devDebug();
7526 int32_t devTimestmp();
7527 #if DEVLEVEL > 1
7528 int32_t setCheat();
7529 #endif //DEVLEVEL > 1
7530 enum
7531 {
7532 dv_log,
7533 // dv_dbg,
7534 dv_tmpstmp,
7535 #if DEVLEVEL > 1
7536 dv_nil,
7537 dv_setcheat,
7538 #endif //DEVLEVEL > 1
7539 dv_max
7540 };
7541 static MENU dev_menu[] =
7542 {
7543 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7544 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7545 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7546 #if DEVLEVEL > 1
7547 { (char *)"", NULL, NULL, 0, NULL },
7548 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7549 #endif //DEVLEVEL > 1
7550 { NULL, NULL, NULL, 0, NULL }
7551 };
7552 int32_t devLogging()
7553 {
7554 dev_logging = !dev_logging;
7555 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7556 return D_O_K;
7557 }
7558 // int32_t devDebug()
7559 // {
7560 // dev_debug = !dev_debug;
7561 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7562 // return D_O_K;
7563 // }
7564 int32_t devTimestmp()
7565 {
7566 dev_timestmp = !dev_timestmp;
7567 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7568 return D_O_K;
7569 }
7570 #if DEVLEVEL > 1
7571 int32_t setCheat()
7572 {
7573 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7574 return D_O_K;
7575 }
7576 #endif //DEVLEVEL > 1
7577 #endif //DEVLEVEL > 0
7578
7579 MENU the_player_menu[] =
7580 {
7581 { (char *)"&Game", NULL, game_menu, 0, NULL },
7582 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7583 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7584 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7585 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7586 #if DEVLEVEL > 0
7587 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7588 #endif
7589 { NULL, NULL, NULL, 0, NULL }
7590 };
7591 int32_t onPauseInBackground()
7592 {
7593 if(jwin_alert3(
7594 "Toggle Pause In Background",
7595 "This action will change whether ZC Player pauses when the window loses focus.",
7596 "",
7597 "Proceed?",
7598 "&Yes",
7599 "&No",
7600 NULL,
7601 'y',
7602 'n',
7603 0,
7604 get_zc_font(font_lfont)) == 1)
7605 {
7606 pause_in_background = pause_in_background ? 0 : 1;
7607 zc_set_config("zeldadx","pause_in_background", pause_in_background);
7608 int switch_type = pause_in_background ? SWITCH_PAUSE : SWITCH_BACKGROUND;
7609 set_display_switch_mode(fullscreen?SWITCH_BACKAMNESIA:switch_type);
7610 set_display_switch_callback(SWITCH_OUT, switch_out_callback);
7611 set_display_switch_callback(SWITCH_IN, switch_in_callback);
7612 }
7613 options_menu[4].flags =(pause_in_background)?D_SELECTED:0;
7614 return D_O_K;
7615 }
7616
7617 int32_t onKeyboardEntry()
7618 {
7619 NameEntryMode=0;
7620 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7621 return D_O_K;
7622 }
7623
7624 int32_t onLetterGridEntry()
7625 {
7626 NameEntryMode=1;
7627 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7628 return D_O_K;
7629 }
7630
7631 int32_t onExtLetterGridEntry()
7632 {
7633 NameEntryMode=2;
7634 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7635 return D_O_K;
7636 }
7637
7638 static BITMAP* oldscreen;
7639 int32_t onFullscreenMenu()
7640 {
7641 // super hacks
7642 screen = oldscreen;
7643 if (onFullscreen() == D_REDRAW)
7644 {
7645 oldscreen = screen;
7646 }
7647 screen = menu_bmp;
7648 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7649 return D_O_K;
7650 }
7651
7652 115 void fix_menu()
7653 {
7654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(!debug_enabled)
7655 115 settings_menu[13].text = NULL;
7656 115 }
7657
7658 static DIALOG system_dlg[] =
7659 {
7660 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7661 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7662 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7663 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7664 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7665 #ifndef ALLEGRO_MACOSX
7666 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7667 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7668 #else
7669 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7670 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7671 #endif
7672 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7673 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7674 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7675 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7676 };
7677
7678 void reset_snapshot_format_menu()
7679 {
7680 for(int32_t i=0; i<ssfmtMAX; ++i)
7681 {
7682 snapshot_format_menu[i].flags=0;
7683 }
7684 }
7685
7686 int32_t onSetSnapshotFormat()
7687 {
7688 switch(active_menu->text[1])
7689 {
7690 case 'B': //"&BMP"
7691 SnapshotFormat=0;
7692 break;
7693
7694 case 'G': //"&GIF"
7695 SnapshotFormat=1;
7696 break;
7697
7698 case 'J': //"&JPG"
7699 SnapshotFormat=2;
7700 break;
7701
7702 case 'P': //"&PNG"
7703 SnapshotFormat=3;
7704 break;
7705
7706 case 'C': //"PC&X"
7707 SnapshotFormat=4;
7708 break;
7709
7710 case 'T': //"&TGA"
7711 SnapshotFormat=5;
7712 break;
7713
7714 case 'L': //"&LBM"
7715 SnapshotFormat=6;
7716 break;
7717 }
7718 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7719
7720 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7721 return D_O_K;
7722 }
7723
7724
7725 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7726 {
7727 PALETTE tmp;
7728
7729 for(int32_t i=0; i<256; i++)
7730 {
7731 tmp[i].r=r;
7732 tmp[i].g=g;
7733 tmp[i].b=b;
7734 }
7735
7736 fade_interpolate(src,tmp,dest,pos,from,to);
7737 }
7738
7739 14 void system_pal(bool force)
7740 {
7741
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14 if(is_sys_pal && !force) return;
7742 14 is_sys_pal = true;
7743 14 load_colorset(gui_colorset, syspal, jwin_a5_colors);
7744 14 hw_palette = &syspal;
7745 14 update_hw_pal = true;
7746 14 }
7747
7748 static uint32_t entered_sys_pal = 0;
7749 14 void enter_sys_pal()
7750 {
7751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
7752 {
7753 if(entered_sys_pal)
7754 ++entered_sys_pal;
7755 return;
7756 }
7757 14 sys_mouse();
7758 14 system_pal(true);
7759 14 ++entered_sys_pal;
7760 14 }
7761 14 void exit_sys_pal()
7762 {
7763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
7764 {
7765
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
7766 {
7767 14 game_pal();
7768 14 game_mouse();
7769 14 }
7770 14 }
7771 14 }
7772
7773 void switch_out_callback()
7774 {
7775 if (pause_in_background && !MenuOpen)
7776 {
7777 System();
7778 }
7779 }
7780
7781 void switch_in_callback()
7782 {
7783 }
7784
7785 422 void game_pal()
7786 {
7787 422 is_sys_pal = false;
7788 422 entered_sys_pal = 0;
7789 422 hw_palette = &RAMpal;
7790 422 update_hw_pal = true;
7791 422 }
7792
7793 static char bar_str[] = "";
7794
7795 14 void music_pause()
7796 {
7797 //al_pause_duh(tmplayer);
7798 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
7799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(zcmixer->oldtrack)
7800 zcmusic_pause(zcmixer->oldtrack, ZCM_PAUSE);
7801 14 zc_midi_pause();
7802 14 }
7803
7804 void music_resume()
7805 {
7806 //al_resume_duh(tmplayer);
7807 zcmusic_pause(zcmusic, ZCM_RESUME);
7808 if (zcmixer->oldtrack)
7809 zcmusic_pause(zcmixer->oldtrack, ZCM_RESUME);
7810 zc_midi_resume();
7811 }
7812
7813 3359 void music_stop()
7814 {
7815 //al_stop_duh(tmplayer);
7816 //unload_duh(tmusic);
7817 //tmusic=NULL;
7818 //tmplayer=NULL;
7819 3359 zcmusic_stop(zcmusic);
7820 3359 zcmusic_unload_file(zcmusic);
7821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3359 times.
3359 if (zcmixer->oldtrack)
7822 {
7823 zcmusic_stop(zcmixer->oldtrack);
7824 zcmusic_unload_file(zcmixer->oldtrack);
7825 }
7826 3359 zcmixer->newtrack = NULL;
7827 3359 zc_stop_midi();
7828 3359 currmidi=-1;
7829 3359 }
7830
7831 void System()
7832 {
7833 mouse_down=gui_mouse_b();
7834 music_pause();
7835 pause_all_sfx();
7836 MenuOpen = true;
7837 enter_sys_pal();
7838 // FONT *oldfont=font;
7839 // font=tfont;
7840
7841 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7842 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
7843
7844 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
7845 #if DEVLEVEL > 1
7846 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
7847 #endif
7848 game_menu[3].flags =
7849 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
7850 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
7851 clear_keybuf();
7852
7853 DIALOG_PLAYER *p;
7854
7855 clear_bitmap(menu_bmp);
7856 oldscreen = screen;
7857 screen = menu_bmp;
7858
7859 p = init_dialog(system_dlg,-1);
7860
7861 // drop the menu on startup if menu button pressed
7862 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
7863 simulate_keypress(KEY_G << 8);
7864
7865 do
7866 {
7867 if(handle_close_btn_quit())
7868 break;
7869
7870 rest(17);
7871
7872 if(mouse_down && !gui_mouse_b())
7873 mouse_down=0;
7874
7875 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
7876 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
7877 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
7878 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
7879 settings_menu[9].flags = TransLayers?D_SELECTED:0;
7880 settings_menu[10].flags = NESquit?D_SELECTED:0;
7881 settings_menu[11].flags = volkeys?D_SELECTED:0;
7882
7883 window_menu[0].flags = DragAspect?D_SELECTED:0;
7884 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
7885 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
7886 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
7887 window_menu[4].flags = stretchGame?D_SELECTED:0;
7888
7889 options_menu[3].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
7890 options_menu[4].flags = (pause_in_background)?D_SELECTED:0;
7891
7892 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
7893 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
7894 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
7895
7896 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
7897 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
7898 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
7899
7900 bool nocheat = (replay_is_replaying() || !Playing
7901 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
7902 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
7903 cheat_menu[0].flags = 0;
7904 refill_menu[4].flags = get_qr(qr_TRUEARROWS) ? 0 : D_DISABLED;
7905 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
7906 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
7907 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
7908 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
7909 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
7910 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
7911 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
7912 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
7913
7914 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
7915 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
7916 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
7917 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
7918 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
7919 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
7920 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
7921 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
7922 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
7923 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
7924 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
7925 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
7926 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
7927 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
7928 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
7929
7930 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
7931 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
7932
7933 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
7934 (char *)"Disable recording new saves" :
7935 (char *)"Enable recording new saves";
7936 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
7937 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
7938 (char *)"Stop recording" :
7939 (char *)"Stop replaying";
7940 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
7941 replay_menu[6].text = replay_is_snapshot_all_frames() ?
7942 (char *)"Disable snapshot all frames" :
7943 (char *)"Enable snapshot all frames";
7944
7945 reset_snapshot_format_menu();
7946 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
7947
7948 if(debug_enabled)
7949 {
7950 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
7951 }
7952
7953 if(gui_mouse_b() && !mouse_down)
7954 break;
7955
7956 // press menu to drop the menu
7957 if(rMbtn())
7958 simulate_keypress(KEY_G << 8);
7959
7960 if(input_idle(true) > after_time())
7961 // run Screeen Saver
7962 {
7963 // Screen saver enabled for now.
7964 clear_keybuf();
7965 Matrix(ss_speed, ss_density, 0);
7966 system_pal(true);
7967 sys_mouse();
7968 broadcast_dialog_message(MSG_DRAW, 0);
7969 }
7970
7971 update_hw_screen();
7972 }
7973 while(update_dialog(p));
7974
7975 screen = oldscreen;
7976
7977 // font=oldfont;
7978 mouse_down=gui_mouse_b();
7979 shutdown_dialog(p);
7980 MenuOpen = false;
7981 if(Quit)
7982 {
7983 kill_sfx();
7984 music_stop();
7985 update_hw_screen();
7986 }
7987 else
7988 {
7989 music_resume();
7990 resume_all_sfx();
7991
7992 if(rc)
7993 ringcolor(false);
7994 }
7995 exit_sys_pal();
7996
7997 eat_buttons();
7998
7999 rc=false;
8000 clear_keybuf();
8001 // text_mode(0);
8002 }
8003
8004 115 void fix_dialogs()
8005 {
8006 115 jwin_center_dialog(about_dlg);
8007 115 jwin_center_dialog(gamepad_dlg);
8008 115 jwin_center_dialog(credits_dlg);
8009 115 jwin_center_dialog(gamemode_dlg);
8010 115 jwin_center_dialog(getnum_dlg);
8011 115 jwin_center_dialog(goto_dlg);
8012 115 jwin_center_dialog(keyboard_control_dlg);
8013 115 jwin_center_dialog(midi_dlg);
8014 115 jwin_center_dialog(quest_dlg);
8015 115 jwin_center_dialog(scrsaver_dlg);
8016 115 jwin_center_dialog(sound_dlg);
8017 115 jwin_center_dialog(triforce_dlg);
8018
8019 // digi_dp[1] += scrx;
8020 // digi_dp[2] += scry;
8021 // midi_dp[1] += scrx;
8022 // midi_dp[2] += scry;
8023 // pan_dp[1] += scrx;
8024 // pan_dp[2] += scry;
8025 // emus_dp[1] += scrx;
8026 // emus_dp[2] += scry;
8027 // buf_dp[1] += scrx;
8028 // buf_dp[2] += scry;
8029 // sfx_dp[1] += scrx;
8030 // sfx_dp[2] += scry;
8031 115 }
8032
8033 /*****************************/
8034 /**** Custom Sound System ****/
8035 /*****************************/
8036
8037 115 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8038 {
8039
2/4
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115 times.
✗ Branch 3 not taken.
115 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8040 }
8041
8042 // Run an NSF, or a MIDI if the NSF is missing somehow.
8043 149 bool try_zcmusic(const char *filename, int32_t track, int32_t midi, int32_t fadeoutframes)
8044 {
8045 149 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8046
8047 // Found it
8048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if(newzcmusic!=NULL)
8049 {
8050 newzcmusic->fadevolume = 10000;
8051 newzcmusic->fadeoutframes = fadeoutframes;
8052
8053 zcmixer->newtrack = newzcmusic;
8054
8055 zcmusic_stop(zcmusic);
8056 zcmusic_unload_file(zcmusic);
8057 zc_stop_midi();
8058
8059 zcmusic=newzcmusic;
8060 int32_t temp_volume = emusic_volume;
8061 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8062 temp_volume = (emusic_volume * FFCore.usr_music_volume) / 10000 / 100;
8063 temp_volume = (temp_volume * zcmusic->fadevolume) / 10000;
8064 zcmusic_play(zcmusic, temp_volume);
8065
8066 if(track>0)
8067 zcmusic_change_track(zcmusic,track);
8068
8069 return true;
8070 }
8071
8072 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8073
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 70 times.
149 else if(midi>-1000)
8074 70 jukebox(midi);
8075
8076 149 return false;
8077 149 }
8078
8079 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8080 {
8081 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8082 // Found it
8083 if(newzcmusic!=NULL)
8084 {
8085 zcmusic_stop(zcmusic);
8086 zcmusic_unload_file(zcmusic);
8087 zc_stop_midi();
8088
8089 zcmusic=newzcmusic;
8090 zcmusic_play(zcmusic, emusic_volume);
8091
8092 if(track>0)
8093 zcmusic_change_track(zcmusic,track);
8094
8095 return true;
8096 }
8097
8098 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8099 else if(midi>-1000)
8100 jukebox(midi);
8101
8102 return false;
8103 }
8104
8105 int32_t get_zcmusicpos()
8106 {
8107 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8108 return debugtracething;
8109 return 0;
8110 }
8111
8112 void set_zcmusicpos(int32_t position)
8113 {
8114 zcmusic_set_curpos(zcmusic, position);
8115 }
8116
8117 void set_zcmusicspeed(int32_t speed)
8118 {
8119 zcmusic_set_speed(zcmusic, speed);
8120 }
8121
8122 int32_t get_zcmusiclen()
8123 {
8124 return zcmusic_get_length(zcmusic);
8125 }
8126
8127 void set_zcmusicloop(double start, double end)
8128 {
8129 zcmusic_set_loop(zcmusic, start, end);
8130 }
8131
8132 63941 void jukebox(int32_t index,int32_t loop)
8133 {
8134
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if (is_headless())
8135 63941 return;
8136
8137 music_stop();
8138
8139 if(index<0) index=MAXMIDIS-1;
8140
8141 if(index>=MAXMIDIS) index=0;
8142
8143 music_stop();
8144
8145 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8146 // stuck notes when a song stops. This fixes it.
8147 if(strcmp(midi_driver->name, "DIGMID")==0)
8148 zc_set_volume(0, 0);
8149
8150 zc_set_volume(-1, mixvol(tunes[index].volume, midi_volume >>1));
8151 zc_play_midi((MIDI*)tunes[index].data,loop);
8152
8153 if(tunes[index].start>0)
8154 zc_midi_seek(tunes[index].start);
8155
8156 midi_loop_start = tunes[index].loop_start;
8157 midi_loop_end = tunes[index].loop_end;
8158
8159 currmidi=index;
8160 master_volume(digi_volume, midi_volume);
8161 //midi_paused=false;
8162 63941 }
8163
8164 63941 void jukebox(int32_t index)
8165 {
8166
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if(index<0) index=MAXMIDIS-1;
8167
8168
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if(index>=MAXMIDIS) index=0;
8169
8170 // do nothing if it's already playing
8171
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63941 if(index==currmidi && midi_pos>=0)
8172 {
8173 return;
8174 }
8175
8176 63941 jukebox(index,tunes[index].loop);
8177 63941 }
8178
8179 16 void play_DmapMusic()
8180 {
8181
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if (is_headless())
8182 16 return;
8183
8184 static char tfile[2048];
8185 static int32_t ttrack=0;
8186 bool domidi=false;
8187
8188 int32_t fadeoutframes = 0;
8189 if (zcmusic != NULL)
8190 fadeoutframes = zcmusic->fadeoutframes;
8191
8192 if(DMaps[currdmap].tmusic[0]!=0)
8193 {
8194 if(zcmusic==NULL ||
8195 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8196 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8197 {
8198 if (DMaps[currdmap].tmusic_xfade_in > 0 || fadeoutframes > 0)
8199 {
8200 if (FFCore.play_enh_music_crossfade(DMaps[currdmap].tmusic, DMaps[currdmap].tmusictrack, DMaps[currdmap].tmusic_xfade_in, fadeoutframes))
8201 {
8202 if (zcmusic != NULL)
8203 {
8204 zcmusic->fadeoutframes = DMaps[currdmap].tmusic_xfade_out;
8205 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8206 }
8207 }
8208 }
8209 else
8210 {
8211 if (zcmusic != NULL)
8212 {
8213 zcmusic_stop(zcmusic);
8214 zcmusic_unload_file(zcmusic);
8215 zcmusic = NULL;
8216 zcmixer->newtrack = NULL;
8217 }
8218
8219 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8220 zcmixer->newtrack = zcmusic;
8221
8222 if (zcmusic != NULL)
8223 {
8224 zc_stop_midi();
8225 strcpy(tfile, DMaps[currdmap].tmusic);
8226 zcmusic_play(zcmusic, emusic_volume);
8227 int32_t temptracks = 0;
8228 temptracks = zcmusic_get_tracks(zcmusic);
8229 temptracks = (temptracks < 2) ? 1 : temptracks;
8230 ttrack = vbound(DMaps[currdmap].tmusictrack, 0, temptracks - 1);
8231 zcmusic_change_track(zcmusic, ttrack);
8232 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8233 }
8234 else
8235 {
8236 tfile[0] = 0;
8237 domidi = true;
8238 }
8239 }
8240 }
8241 }
8242 else
8243 {
8244 if (DMaps[currdmap].midi == 0 && fadeoutframes > 0 && zcmusic != NULL && strcmp(zcmusic->filename, DMaps[currdmap].tmusic) != 0)
8245 {
8246 FFCore.play_enh_music_crossfade(NULL, DMaps[currdmap].tmusictrack, DMaps[currdmap].tmusic_xfade_in, fadeoutframes);
8247 }
8248 else
8249 {
8250 domidi = true;
8251 }
8252 }
8253
8254 if(domidi)
8255 {
8256 int32_t m=DMaps[currdmap].midi;
8257
8258 switch(m)
8259 {
8260 case 1:
8261 jukebox(ZC_MIDI_OVERWORLD);
8262 break;
8263
8264 case 2:
8265 jukebox(ZC_MIDI_DUNGEON);
8266 break;
8267
8268 case 3:
8269 jukebox(ZC_MIDI_LEVEL9);
8270 break;
8271
8272 default:
8273 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8274 jukebox(m+MIDIOFFSET_DMAP);
8275 else
8276 music_stop();
8277 }
8278 }
8279 16 }
8280
8281 15753 void playLevelMusic()
8282 {
8283
1/2
✓ Branch 0 taken 15753 times.
✗ Branch 1 not taken.
15753 if (is_headless())
8284 15753 return;
8285
8286 int32_t m=tmpscr->screen_midi;
8287
8288 switch(m)
8289 {
8290 case -2:
8291 music_stop();
8292 break;
8293
8294 case -1:
8295 play_DmapMusic();
8296 break;
8297
8298 case 1:
8299 jukebox(ZC_MIDI_OVERWORLD);
8300 break;
8301
8302 case 2:
8303 jukebox(ZC_MIDI_DUNGEON);
8304 break;
8305
8306 case 3:
8307 jukebox(ZC_MIDI_LEVEL9);
8308 break;
8309
8310 default:
8311 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8312 jukebox(m+MIDIOFFSET_MAPSCR);
8313 else
8314 music_stop();
8315 }
8316 15753 }
8317
8318 115 void master_volume(int32_t dv,int32_t mv)
8319 {
8320
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
✓ Branch 2 taken 115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 115 times.
✗ Branch 7 not taken.
115 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8321
8322
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
✓ Branch 2 taken 115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 115 times.
✗ Branch 7 not taken.
115 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8323
8324
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
✓ Branch 2 taken 115 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 115 times.
115 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8325 115 int32_t temp_vol = midi_volume;
8326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8327 115 temp_vol = (midi_volume * FFCore.usr_music_volume) / 10000 / 100;
8328 115 zc_set_volume(digi_volume,mixvol(tunes[i].volume, temp_vol));
8329 115 }
8330
8331 /*****************/
8332 /***** SFX *****/
8333 /*****************/
8334
8335 // array of voices, one for each sfx sample in the data file
8336 // 0+ = voice #
8337 // -1 = voice not allocated
8338 115 void Z_init_sound()
8339 {
8340
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<WAV_COUNT; i++)
8341 29440 sfx_voice[i]=-1;
8342
8343 115 const char* midis[ZC_MIDI_COUNT] = {
8344 "assets/dungeon.mid",
8345 "assets/ending.mid",
8346 "assets/gameover.mid",
8347 "assets/level9.mid",
8348 "assets/overworld.mid",
8349 "assets/title.mid",
8350 "assets/triforce.mid",
8351 };
8352
2/2
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 115 times.
920 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8353 {
8354 805 tunes[i].data = load_midi(midis[i]);
8355
1/2
✓ Branch 0 taken 805 times.
✗ Branch 1 not taken.
805 if (!tunes[i].data)
8356 Z_error_fatal("Missing required file %s\n", midis[i]);
8357 805 }
8358
8359
2/2
✓ Branch 0 taken 28980 times.
✓ Branch 1 taken 115 times.
29095 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8360 28980 tunes[ZC_MIDI_COUNT+j].data=NULL;
8361
8362 115 master_volume(digi_volume,midi_volume);
8363 115 }
8364
8365 // returns number of voices currently allocated
8366 int32_t sfx_count()
8367 {
8368 int32_t c=0;
8369
8370 for(int32_t i=0; i<WAV_COUNT; i++)
8371 if(sfx_voice[i]!=-1)
8372 ++c;
8373
8374 return c;
8375 }
8376
8377 // clean up finished samples
8378 9216893 void sfx_cleanup()
8379 {
8380
2/2
✓ Branch 0 taken 2359524608 times.
✓ Branch 1 taken 9216893 times.
2368741501 for(int32_t i=0; i<WAV_COUNT; i++)
8381
3/4
✓ Branch 0 taken 619381 times.
✓ Branch 1 taken 2358905227 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 619381 times.
2360143989 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8382 {
8383 619381 deallocate_voice(sfx_voice[i]);
8384 619381 sfx_voice[i]=-1;
8385 619381 }
8386 9216893 }
8387
8388 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8389 // if a voice is already allocated (and/or playing), then it just returns true
8390 // Returns true: voice is allocated
8391 // false: unsuccessful
8392 963799 bool sfx_init(int32_t index)
8393 {
8394 // check index
8395
3/4
✓ Branch 0 taken 721410 times.
✓ Branch 1 taken 242389 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 721410 times.
963799 if(index<=0 || index>=WAV_COUNT)
8396 242389 return false;
8397
8398
2/2
✓ Branch 0 taken 102011 times.
✓ Branch 1 taken 619399 times.
721410 if(sfx_voice[index]==-1)
8399 {
8400
2/2
✓ Branch 0 taken 209876 times.
✓ Branch 1 taken 409523 times.
619399 if(sfxdat)
8401 {
8402
1/2
✓ Branch 0 taken 209876 times.
✗ Branch 1 not taken.
209876 if(index<Z35)
8403 {
8404 209876 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8405 209876 }
8406 else
8407 {
8408 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8409 }
8410 209876 }
8411 else
8412 {
8413 409523 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8414 }
8415
8416 619399 int32_t temp_volume = sfx_volume;
8417
2/4
✓ Branch 0 taken 619399 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 619399 times.
✗ Branch 3 not taken.
619399 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8418 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8419 619399 voice_set_volume(sfx_voice[index], temp_volume);
8420 619399 }
8421
8422 721410 return sfx_voice[index] != -1;
8423 963799 }
8424
8425 int32_t sfx_get_default_freq(int32_t index)
8426 {
8427 if (sfxdat)
8428 {
8429 if (index < Z35)
8430 {
8431 return ((SAMPLE*)sfxdata[index].dat)->freq;
8432 }
8433 else
8434 {
8435 return ((SAMPLE*)sfxdata[Z35].dat)->freq;
8436 }
8437 }
8438 else
8439 {
8440 return customsfxdata[index].freq;
8441 }
8442 }
8443
8444 int32_t sfx_get_length(int32_t index)
8445 {
8446 if (sfxdat)
8447 {
8448 if (index < Z35)
8449 {
8450 return int32_t(((SAMPLE*)sfxdata[index].dat)->len);
8451 }
8452 else
8453 {
8454 return int32_t(((SAMPLE*)sfxdata[Z35].dat)->len);
8455 }
8456 }
8457 else
8458 {
8459 return int32_t(customsfxdata[index].len);
8460 }
8461 }
8462
8463 // plays an sfx sample
8464 963799 void sfx(int32_t index,int32_t pan,bool loop, bool restart, int32_t vol, int32_t freq)
8465 {
8466
2/2
✓ Branch 0 taken 721410 times.
✓ Branch 1 taken 242389 times.
963799 if(!sfx_init(index))
8467 242389 return;
8468
1/2
✓ Branch 0 taken 721410 times.
✗ Branch 1 not taken.
721410 if (!is_headless())
8469 {
8470 voice_set_playmode(sfx_voice[index], loop ? PLAYMODE_LOOP : PLAYMODE_PLAY);
8471 voice_set_pan(sfx_voice[index], pan);
8472
8473 // Only used by ZScript currently
8474 if (freq <= -1)
8475 {
8476 freq = sfx_get_default_freq(index);
8477 }
8478 voice_set_frequency(sfx_voice[index], freq);
8479
8480 // Only used by ZScript currently
8481 int32_t temp_volume = (sfx_volume * vol) / 10000 / 100;
8482 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8483 temp_volume = (temp_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8484 voice_set_volume(sfx_voice[index], temp_volume);
8485
8486 int32_t pos = voice_get_position(sfx_voice[index]);
8487
8488 if (restart) voice_set_position(sfx_voice[index], 0);
8489
8490 if (pos <= 0)
8491 voice_start(sfx_voice[index]);
8492 }
8493
8494
3/4
✓ Branch 0 taken 397878 times.
✓ Branch 1 taken 323532 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 397878 times.
721410 if (restart && replay_is_debug())
8495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 397878 times.
397878 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8496 963799 }
8497
8498 // true if sfx is allocated
8499 68051 bool sfx_allocated(int32_t index)
8500 {
8501
3/4
✓ Branch 0 taken 9922 times.
✓ Branch 1 taken 58129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9922 times.
68051 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8502 }
8503
8504 // start it (in loop mode) if it's not already playing,
8505 // otherwise adjust it to play in loop mode -DD
8506 178222 void cont_sfx(int32_t index)
8507 {
8508
1/2
✓ Branch 0 taken 178222 times.
✗ Branch 1 not taken.
178222 if (is_headless())
8509 178222 return;
8510
8511 if(!sfx_init(index))
8512 {
8513 return;
8514 }
8515
8516 if(voice_get_position(sfx_voice[index])<=0)
8517 {
8518 voice_set_position(sfx_voice[index],0);
8519 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8520 voice_start(sfx_voice[index]);
8521 }
8522 else
8523 {
8524 adjust_sfx(index, 128, true);
8525 }
8526 178222 }
8527
8528 // adjust parameters while playing
8529 4075 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8530 {
8531
4/6
✓ Branch 0 taken 2315 times.
✓ Branch 1 taken 1760 times.
✓ Branch 2 taken 2315 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2315 times.
4075 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8532 4075 return;
8533
8534 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8535 voice_set_pan(sfx_voice[index],pan);
8536 4075 }
8537
8538 // pauses a voice
8539 1725 void pause_sfx(int32_t index)
8540 {
8541
3/6
✓ Branch 0 taken 1725 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1725 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1725 times.
1725 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8542 voice_stop(sfx_voice[index]);
8543 1725 }
8544
8545 // resumes a voice
8546 747 void resume_sfx(int32_t index)
8547 {
8548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 747 times.
747 if (is_headless())
8549 747 return;
8550
8551 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8552 voice_start(sfx_voice[index]);
8553 747 }
8554
8555 // pauses all active voices
8556 448 void pause_all_sfx()
8557 {
8558
2/2
✓ Branch 0 taken 114688 times.
✓ Branch 1 taken 448 times.
115136 for(int32_t i=0; i<WAV_COUNT; i++)
8559
2/2
✓ Branch 0 taken 114687 times.
✓ Branch 1 taken 1 times.
114689 if(sfx_voice[i]!=-1)
8560 1 voice_stop(sfx_voice[i]);
8561 448 }
8562
8563 // resumes all paused voices
8564 434 void resume_all_sfx()
8565 {
8566
2/2
✓ Branch 0 taken 111104 times.
✓ Branch 1 taken 434 times.
111538 for(int32_t i=0; i<WAV_COUNT; i++)
8567
1/2
✓ Branch 0 taken 111104 times.
✗ Branch 1 not taken.
111104 if(sfx_voice[i]!=-1)
8568 voice_start(sfx_voice[i]);
8569 434 }
8570
8571 // stops an sfx and deallocates the voice
8572 7338577 void stop_sfx(int32_t index)
8573 {
8574
3/4
✓ Branch 0 taken 6190026 times.
✓ Branch 1 taken 1148551 times.
✓ Branch 2 taken 6190026 times.
✗ Branch 3 not taken.
7338577 if(index<=0 || index>=WAV_COUNT)
8575 1148551 return;
8576
8577
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6190014 times.
6190026 if(sfx_voice[index]!=-1)
8578 {
8579 12 deallocate_voice(sfx_voice[index]);
8580 12 sfx_voice[index]=-1;
8581 12 }
8582 7338577 }
8583
8584 // Stops SFX played by Hero's item of the given family
8585 128638 void stop_item_sfx(int32_t family)
8586 {
8587 128638 int32_t id=current_item_id(family);
8588
8589
2/2
✓ Branch 0 taken 128083 times.
✓ Branch 1 taken 555 times.
128638 if(id<0)
8590 128083 return;
8591
8592 555 stop_sfx(itemsbuf[id].usesound);
8593 128638 }
8594
8595 3221 void kill_sfx()
8596 {
8597
2/2
✓ Branch 0 taken 824576 times.
✓ Branch 1 taken 3221 times.
827797 for(int32_t i=0; i<WAV_COUNT; i++)
8598
2/2
✓ Branch 0 taken 824570 times.
✓ Branch 1 taken 6 times.
824582 if(sfx_voice[i]!=-1)
8599 {
8600 6 deallocate_voice(sfx_voice[i]);
8601 6 sfx_voice[i]=-1;
8602 6 }
8603 3221 }
8604
8605 659526 int32_t pan(int32_t x)
8606 {
8607
1/4
✓ Branch 0 taken 659526 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
659526 switch(pan_style)
8608 {
8609 case 0:
8610 return 128;
8611
8612 case 1:
8613 659526 return vbound((x>>1)+68,0,255);
8614
8615 case 2:
8616 return vbound(((x*3)>>2)+36,0,255);
8617 }
8618
8619 return vbound(x,0,255);
8620 659526 }
8621
8622 /*******************************/
8623 /******* Input Handlers ********/
8624 /*******************************/
8625
8626 25090398 bool joybtn(int32_t b)
8627 {
8628
1/2
✓ Branch 0 taken 25090398 times.
✗ Branch 1 not taken.
25090398 if(b == 0)
8629 return false;
8630
1/2
✓ Branch 0 taken 25090398 times.
✗ Branch 1 not taken.
25090398 if (b-1 >= joy[joystick_index].num_buttons)
8631 25090398 return false;
8632
8633 return joy[joystick_index].button[b-1].b !=0;
8634 25090398 }
8635
8636 bool joystick(int32_t s)
8637 {
8638 if(s < 0)
8639 return false;
8640 if (s >= joy[joystick_index].num_sticks)
8641 return false;
8642
8643 for (int i = 0; i < joy[joystick_index].stick[s].num_axis; i++)
8644 {
8645 if (joy[joystick_index].stick[s].axis[i].d1 || joy[joystick_index].stick[s].axis[i].d2)
8646 return true;
8647 }
8648 return false;
8649 }
8650
8651 const char* joybtn_name(int32_t b)
8652 {
8653 if (b <= 0 || b > joy[joystick_index].num_buttons)
8654 return "";
8655
8656 return joy[joystick_index].button[b-1].name;
8657 }
8658
8659 const char* joystick_name(int32_t s)
8660 {
8661 if (s < 0 || s >= joy[joystick_index].num_sticks)
8662 return "";
8663
8664 return joy[joystick_index].stick[s].name;
8665 }
8666
8667 int32_t next_press_key();
8668
8669 int32_t next_joy_input(bool buttons)
8670 {
8671 clear_keybuf();
8672
8673 //first, we need to wait until they're pressing no buttons
8674 for(;;)
8675 {
8676 if(keypressed())
8677 {
8678 switch(readkey()>>8)
8679 {
8680 case KEY_ESC:
8681 return -1;
8682
8683 case KEY_SPACE:
8684 return 0;
8685 }
8686 }
8687
8688 poll_joystick();
8689 bool done = true;
8690
8691 if (buttons)
8692 {
8693 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8694 {
8695 if(joybtn(i)) done = false;
8696 }
8697 }
8698 else
8699 {
8700 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8701 {
8702 if(joystick(i)) done = false;
8703 }
8704 }
8705
8706 if(done) break;
8707 rest(1);
8708 }
8709
8710 //now, we need to wait for them to press any button
8711 for(;;)
8712 {
8713 if(keypressed())
8714 {
8715 switch(readkey()>>8)
8716 {
8717 case KEY_ESC:
8718 return -1;
8719
8720 case KEY_SPACE:
8721 return 0;
8722 }
8723 }
8724
8725 poll_joystick();
8726
8727 if (buttons)
8728 {
8729 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8730 {
8731 if(joybtn(i))
8732 return i;
8733 }
8734 }
8735 else
8736 {
8737 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8738 {
8739 if(joystick(i))
8740 return i;
8741 }
8742 }
8743 rest(1);
8744 }
8745 }
8746
8747 1205771 static bool rButton(bool &btn, bool &flag, bool rawbtn)
8748 {
8749
2/2
✓ Branch 0 taken 1201420 times.
✓ Branch 1 taken 4351 times.
1205771 bool ret = btn && !flag;
8750 1205771 flag = rawbtn;
8751
8752 1205771 return ret;
8753 }
8754 190775420 static bool rButton(bool &btn, bool &flag)
8755 {
8756
2/2
✓ Branch 0 taken 183932818 times.
✓ Branch 1 taken 6842602 times.
190775420 bool ret = btn && !flag;
8757 190775420 flag = btn;
8758
8759 190775420 return ret;
8760 }
8761 2888422 static bool rButtonPeek(bool btn, bool flag)
8762 {
8763
2/2
✓ Branch 0 taken 2685421 times.
✓ Branch 1 taken 203001 times.
2888422 if(!btn)
8764 {
8765 2685421 return false;
8766 }
8767
2/2
✓ Branch 0 taken 17917 times.
✓ Branch 1 taken 185084 times.
203001 else if(!flag)
8768 {
8769 17917 return true;
8770 }
8771
8772 185084 return false;
8773 2888422 }
8774
8775 // Updated only by keyboard/gamepad.
8776 // If in replay mode, this is set directly by the replay system.
8777 // This should never be read from directly - use control_state instead.
8778 bool raw_control_state[ZC_CONTROL_STATES];
8779
8780 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
8781 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
8782 // lasts until the next call to load_control_state.
8783 bool control_state[ZC_CONTROL_STATES];
8784 bool disable_control[ZC_CONTROL_STATES];
8785 bool drunk_toggle_state[11];
8786 bool disabledKeys[127];
8787 bool KeyInput[127];
8788 bool KeyPress[127];
8789
8790 bool key_current_frame[127];
8791 bool key_previous_frame[127];
8792
8793 static bool key_system[127];
8794 static bool key_system_previous[127];
8795 static bool key_system_press[127];
8796
8797 bool button_press[ZC_CONTROL_STATES];
8798 bool button_hold[ZC_CONTROL_STATES];
8799
8800 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
8801 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
8802 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
8803 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
8804 #define STICK_PRECISION 56 //define your own sensitivity
8805
8806 7799730 void load_control_state()
8807 {
8808 7799730 load_control_called_this_frame = true;
8809
8810
2/2
✓ Branch 0 taken 4833196 times.
✓ Branch 1 taken 2966534 times.
7799730 if (replay_version_check(8, 11))
8811 {
8812
2/2
✓ Branch 0 taken 53397612 times.
✓ Branch 1 taken 2966534 times.
56364146 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8813 53397612 down_control_states[i] = raw_control_state[i];
8814 2966534 }
8815
8816
1/2
✓ Branch 0 taken 7799730 times.
✗ Branch 1 not taken.
7799730 if (!replay_is_replaying())
8817 {
8818 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
8819 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
8820 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
8821 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
8822 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
8823 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
8824 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
8825 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
8826 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
8827 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
8828 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
8829 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
8830 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
8831 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
8832
8833 if(num_joysticks != 0)
8834 {
8835 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
8836 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
8837 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
8838 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
8839 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
8840 }
8841 else
8842 {
8843 raw_control_state[14] = false;
8844 raw_control_state[15] = false;
8845 raw_control_state[16] = false;
8846 raw_control_state[17] = false;
8847 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
8848 }
8849 }
8850
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 7799727 times.
7799730 if (replay_is_active())
8851 {
8852
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 6784512 times.
7799727 if (replay_get_version() < 3)
8853 1015215 replay_poll();
8854
3/4
✓ Branch 0 taken 6784512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5023137 times.
✓ Branch 3 taken 1761375 times.
6784512 else if (replay_is_replaying() && replay_get_version() < 6)
8855 1761375 replay_peek_input();
8856
3/4
✓ Branch 0 taken 5023137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2056603 times.
✓ Branch 3 taken 2966534 times.
5023137 else if (replay_is_replaying() && replay_version_check(8, 11))
8857 2966534 replay_peek_input();
8858
2/2
✓ Branch 0 taken 6696416 times.
✓ Branch 1 taken 1103311 times.
7799727 if (replay_get_version() == 8)
8859 1103311 update_keys();
8860 7799727 }
8861
8862 // Some test replay files were made before a serious input bug was fixed, so instead
8863 // of re-doing them or tossing them out, just check for that zplay version.
8864
3/4
✓ Branch 0 taken 7799724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 7677824 times.
7799730 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
8865
2/2
✓ Branch 0 taken 140395032 times.
✓ Branch 1 taken 7799724 times.
148194756 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8866 {
8867 140395032 control_state[i] = raw_control_state[i];
8868
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 90907722 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
140395032 if (botched_input && !control_state[i])
8869 47077142 down_control_states[i] = false;
8870 140395032 }
8871 7799724 bool did_bad_cutscene_btn = false;
8872
2/2
✓ Branch 0 taken 7799724 times.
✓ Branch 1 taken 140395032 times.
148194756 for(int q = 0; q < 18; ++q)
8873
4/4
✓ Branch 0 taken 6463294 times.
✓ Branch 1 taken 133931738 times.
✓ Branch 2 taken 6462560 times.
✓ Branch 3 taken 734 times.
140395766 if(control_state[q] && !active_cutscene.can_button(q))
8874 {
8875 734 control_state[q] = false;
8876 734 did_bad_cutscene_btn = true;
8877 734 }
8878
2/2
✓ Branch 0 taken 7799209 times.
✓ Branch 1 taken 515 times.
7799724 if(did_bad_cutscene_btn)
8879 515 active_cutscene.error();
8880
8881 7799724 button_press[0]=rButton(control_state[0],button_hold[0]);
8882 7799724 button_press[1]=rButton(control_state[1],button_hold[1]);
8883 7799724 button_press[2]=rButton(control_state[2],button_hold[2]);
8884 7799724 button_press[3]=rButton(control_state[3],button_hold[3]);
8885 7799724 button_press[4]=rButton(control_state[4],button_hold[4]);
8886 7799724 button_press[5]=rButton(control_state[5],button_hold[5]);
8887 7799724 button_press[6]=rButton(control_state[6],button_hold[6]);
8888 7799724 button_press[7]=rButton(control_state[7],button_hold[7]);
8889 7799724 button_press[8]=rButton(control_state[8],button_hold[8]);
8890 7799724 button_press[9]=rButton(control_state[9],button_hold[9]);
8891 7799724 button_press[10]=rButton(control_state[10],button_hold[10]);
8892 7799724 button_press[11]=rButton(control_state[11],button_hold[11]);
8893 7799724 button_press[12]=rButton(control_state[12],button_hold[12]);
8894 7799724 button_press[13]=rButton(control_state[13],button_hold[13]);
8895 7799724 button_press[14]=rButton(control_state[14],button_hold[14]);
8896 7799724 button_press[15]=rButton(control_state[15],button_hold[15]);
8897 7799724 button_press[16]=rButton(control_state[16],button_hold[16]);
8898 7799724 button_press[17]=rButton(control_state[17],button_hold[17]);
8899 7799724 }
8900
8901 // Returns true if any game key is pressed. This is needed because keypressed()
8902 // doesn't detect modifier keys and control_state[] can be modified by scripts.
8903 40244479 bool zc_key_pressed()
8904 //may also need to use zc_getrawkey
8905 {
8906
7/10
✓ Branch 0 taken 32592821 times.
✓ Branch 1 taken 7651658 times.
✓ Branch 2 taken 7651658 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7651658 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6395367 times.
✓ Branch 7 taken 6395367 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2461398 times.
42705877 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
8907
4/6
✓ Branch 0 taken 6395367 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6395367 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4843378 times.
✓ Branch 5 taken 4843378 times.
6395367 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
8908
4/6
✓ Branch 0 taken 4843378 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4843378 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3142751 times.
✓ Branch 5 taken 3142751 times.
4843378 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
8909
4/6
✓ Branch 0 taken 3142751 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3142751 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2731904 times.
✓ Branch 5 taken 2731904 times.
3142751 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
8910
1/2
✓ Branch 0 taken 2731904 times.
✗ Branch 1 not taken.
2731904 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
8911
3/4
✓ Branch 0 taken 2612497 times.
✓ Branch 1 taken 119407 times.
✓ Branch 2 taken 2612497 times.
✗ Branch 3 not taken.
2731904 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
8912
3/4
✓ Branch 0 taken 2493608 times.
✓ Branch 1 taken 118889 times.
✓ Branch 2 taken 2493608 times.
✗ Branch 3 not taken.
2612497 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
8913
3/4
✓ Branch 0 taken 2478463 times.
✓ Branch 1 taken 15145 times.
✓ Branch 2 taken 2478463 times.
✗ Branch 3 not taken.
2493608 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
8914
3/4
✓ Branch 0 taken 2464964 times.
✓ Branch 1 taken 13499 times.
✓ Branch 2 taken 2464964 times.
✗ Branch 3 not taken.
2478463 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
8915
3/4
✓ Branch 0 taken 2462474 times.
✓ Branch 1 taken 2490 times.
✓ Branch 2 taken 2462474 times.
✗ Branch 3 not taken.
2464964 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
8916
3/4
✓ Branch 0 taken 2462256 times.
✓ Branch 1 taken 218 times.
✓ Branch 2 taken 2462256 times.
✗ Branch 3 not taken.
2462474 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
8917
3/4
✓ Branch 0 taken 2461417 times.
✓ Branch 1 taken 839 times.
✓ Branch 2 taken 2461417 times.
✗ Branch 3 not taken.
2462256 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
8918
2/4
✓ Branch 0 taken 2461417 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461417 times.
✗ Branch 3 not taken.
2461417 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
8919
2/2
✓ Branch 0 taken 2461398 times.
✓ Branch 1 taken 19 times.
2461417 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
8920 72009881 return true;
8921
8922 2461398 return false;
8923 9285637 }
8924
8925 150315062 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8926 {
8927 150315062 bool ret = false, drunkstate = false, rawret = false;;
8928 150315062 bool* flag = &down_control_states[btn];
8929
2/7
✓ Branch 0 taken 141020088 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 9294974 times.
150315062 switch(btn)
8930 {
8931 case btnF12:
8932 ret = zc_getkey(KEY_F12, ignoreDisable);
8933 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
8934 eatEntirely = false;
8935 break;
8936 case btnF11:
8937 ret = zc_getkey(KEY_F11, ignoreDisable);
8938 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
8939 eatEntirely = false;
8940 break;
8941 case btnF5:
8942 ret = zc_getkey(KEY_F5, ignoreDisable);
8943 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
8944 eatEntirely = false;
8945 break;
8946 case btnQ:
8947 ret = zc_getkey(KEY_Q, ignoreDisable);
8948 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
8949 eatEntirely = false;
8950 break;
8951 case btnI:
8952 ret = zc_getkey(KEY_I, ignoreDisable);
8953 rawret = zc_getrawkey(KEY_I, ignoreDisable);
8954 eatEntirely = false;
8955 break;
8956 case btnM:
8957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9294974 times.
9294974 if(FFCore.kb_typing_mode) return false;
8958 9294974 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
8959 9294974 eatEntirely = false;
8960 9294974 break;
8961 default: //control_state[] index
8962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 141020088 times.
141020088 if(FFCore.kb_typing_mode) return false;
8963
5/6
✓ Branch 0 taken 140220309 times.
✓ Branch 1 taken 799779 times.
✓ Branch 2 taken 2220072 times.
✓ Branch 3 taken 138000237 times.
✓ Branch 4 taken 2220072 times.
✗ Branch 5 not taken.
141020088 if(!ignoreDisable && get_qr(qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
8964
2/2
✓ Branch 0 taken 8034219 times.
✓ Branch 1 taken 132985869 times.
141020088 else if(btn<11) drunkstate = drunk_toggle_state[btn];
8965
4/4
✓ Branch 0 taken 126855451 times.
✓ Branch 1 taken 14164637 times.
✓ Branch 2 taken 3004 times.
✓ Branch 3 taken 14161633 times.
155184725 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
8966 141020088 rawret = raw_control_state[btn];
8967 141020088 }
8968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150315062 times.
150315062 assert(flag);
8969
2/2
✓ Branch 0 taken 95840481 times.
✓ Branch 1 taken 54474581 times.
150315062 if(press)
8970 {
8971
2/2
✓ Branch 0 taken 2888422 times.
✓ Branch 1 taken 51586159 times.
54474581 if(peek)
8972 2888422 ret = rButtonPeek(ret, *flag);
8973
2/2
✓ Branch 0 taken 50380388 times.
✓ Branch 1 taken 1205771 times.
51586159 else if(get_qr(qr_BROKEN_INPUT_DOWN_STATE)) ret = rButton(ret, *flag);
8974 1205771 else ret = rButton(ret, *flag, rawret);
8975 54474581 }
8976
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150315062 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150315062 if(eatEntirely && ret) control_state[btn] = false;
8977
3/4
✓ Branch 0 taken 112360541 times.
✓ Branch 1 taken 37954521 times.
✓ Branch 2 taken 112360541 times.
✗ Branch 3 not taken.
150315062 if(drunk && drunkstate) ret = !ret;
8978 150315062 return ret;
8979 150315062 }
8980
8981 7464265 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8982 {
8983 7464265 byte ret = 0;
8984
2/2
✓ Branch 0 taken 5485508 times.
✓ Branch 1 taken 1978757 times.
7464265 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
8985
2/2
✓ Branch 0 taken 7333451 times.
✓ Branch 1 taken 130814 times.
7464265 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
8986
2/2
✓ Branch 0 taken 7333576 times.
✓ Branch 1 taken 130689 times.
7464265 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
8987
2/2
✓ Branch 0 taken 7333576 times.
✓ Branch 1 taken 130689 times.
7464265 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
8988
2/2
✓ Branch 0 taken 7333576 times.
✓ Branch 1 taken 130689 times.
7464265 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
8989
2/2
✓ Branch 0 taken 7333576 times.
✓ Branch 1 taken 130689 times.
7464265 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
8990
2/2
✓ Branch 0 taken 7333576 times.
✓ Branch 1 taken 130689 times.
7464265 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
8991
2/2
✓ Branch 0 taken 7333576 times.
✓ Branch 1 taken 130689 times.
7464265 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
8992 7464265 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
8993 }
8994
8995 1114 byte checkIntBtnVal(byte intbtn, byte vals)
8996 {
8997 1114 return intbtn&vals;
8998 }
8999
9000 1767317 bool Up()
9001 {
9002 1767317 return getInput(btnUp);
9003 }
9004 147132 bool Down()
9005 {
9006 147132 return getInput(btnDown);
9007 }
9008 257465 bool Left()
9009 {
9010 257465 return getInput(btnLeft);
9011 }
9012 286650 bool Right()
9013 {
9014 286650 return getInput(btnRight);
9015 }
9016 164850 bool cAbtn()
9017 {
9018 164850 return getInput(btnA);
9019 }
9020 1411781 bool cBbtn()
9021 {
9022 1411781 return getInput(btnB);
9023 }
9024 bool cSbtn()
9025 {
9026 return getInput(btnS);
9027 }
9028 68744 bool cLbtn()
9029 {
9030 68744 return getInput(btnL);
9031 }
9032 68744 bool cRbtn()
9033 {
9034 68744 return getInput(btnR);
9035 }
9036 bool cPbtn()
9037 {
9038 return getInput(btnP);
9039 }
9040 bool cEx1btn()
9041 {
9042 return getInput(btnEx1);
9043 }
9044 bool cEx2btn()
9045 {
9046 return getInput(btnEx2);
9047 }
9048 bool cEx3btn()
9049 {
9050 return getInput(btnEx3);
9051 }
9052 bool cEx4btn()
9053 {
9054 return getInput(btnEx4);
9055 }
9056 bool AxisUp()
9057 {
9058 return getInput(btnAxisUp);
9059 }
9060 bool AxisDown()
9061 {
9062 return getInput(btnAxisDown);
9063 }
9064 bool AxisLeft()
9065 {
9066 return getInput(btnAxisLeft);
9067 }
9068 bool AxisRight()
9069 {
9070 return getInput(btnAxisRight);
9071 }
9072
9073 bool cMbtn()
9074 {
9075 return getInput(btnM);
9076 }
9077 bool cF12()
9078 {
9079 return getInput(btnF12);
9080 }
9081 bool cF11()
9082 {
9083 return getInput(btnF11);
9084 }
9085 bool cF5()
9086 {
9087 return getInput(btnF5);
9088 }
9089 bool cQ()
9090 {
9091 return getInput(btnQ);
9092 }
9093 bool cI()
9094 {
9095 return getInput(btnI);
9096 }
9097
9098 130270 bool rUp()
9099 {
9100 130270 return getInput(btnUp, true);
9101 }
9102 130174 bool rDown()
9103 {
9104 130174 return getInput(btnDown, true);
9105 }
9106 130122 bool rLeft()
9107 {
9108 130122 return getInput(btnLeft, true);
9109 }
9110 129657 bool rRight()
9111 {
9112 129657 return getInput(btnRight, true);
9113 }
9114 1295 bool rAbtn()
9115 {
9116 1295 return getInput(btnA, true);
9117 }
9118 1295 bool rBbtn()
9119 {
9120 1295 return getInput(btnB, true);
9121 }
9122 7396079 bool rSbtn()
9123 {
9124 7396079 return getInput(btnS, true);
9125 }
9126 9285637 bool rMbtn()
9127 {
9128 9285637 return getInput(btnM, true);
9129 }
9130 129441 bool rLbtn()
9131 {
9132 129441 return getInput(btnL, true);
9133 }
9134 129436 bool rRbtn()
9135 {
9136 129436 return getInput(btnR, true);
9137 }
9138 7332543 bool rPbtn()
9139 {
9140 7332543 return getInput(btnP, true);
9141 }
9142 bool rEx1btn()
9143 {
9144 return getInput(btnEx1, true);
9145 }
9146 bool rEx2btn()
9147 {
9148 return getInput(btnEx2, true);
9149 }
9150 139523 bool rEx3btn()
9151 {
9152 139523 return getInput(btnEx3, true);
9153 }
9154 139523 bool rEx4btn()
9155 {
9156 139523 return getInput(btnEx4, true);
9157 }
9158 bool rAxisUp()
9159 {
9160 return getInput(btnAxisUp, true);
9161 }
9162 bool rAxisDown()
9163 {
9164 return getInput(btnAxisDown, true);
9165 }
9166 bool rAxisLeft()
9167 {
9168 return getInput(btnAxisLeft, true);
9169 }
9170 bool rAxisRight()
9171 {
9172 return getInput(btnAxisRight, true);
9173 }
9174
9175 bool rF11()
9176 {
9177 return getInput(btnF11, true);
9178 }
9179 bool rQ()
9180 {
9181 return getInput(btnQ, true);
9182 }
9183 bool rI()
9184 {
9185 return getInput(btnI, true);
9186 }
9187
9188 18224658 bool DrunkUp()
9189 {
9190 18224658 return getInput(btnUp, false, true);
9191 }
9192 16887819 bool DrunkDown()
9193 {
9194 16887819 return getInput(btnDown, false, true);
9195 }
9196 10287783 bool DrunkLeft()
9197 {
9198 10287783 return getInput(btnLeft, false, true);
9199 }
9200 8833709 bool DrunkRight()
9201 {
9202 8833709 return getInput(btnRight, false, true);
9203 }
9204 8034835 bool DrunkcAbtn()
9205 {
9206 8034835 return getInput(btnA, false, true);
9207 }
9208 8016437 bool DrunkcBbtn()
9209 {
9210 8016437 return getInput(btnB, false, true);
9211 }
9212 7263413 bool DrunkcEx1btn()
9213 {
9214 7263413 return getInput(btnEx1, false, true);
9215 }
9216 7263433 bool DrunkcEx2btn()
9217 {
9218 7263433 return getInput(btnEx2, false, true);
9219 }
9220 bool DrunkcSbtn()
9221 {
9222 return getInput(btnS, false, true);
9223 }
9224 bool DrunkcMbtn()
9225 {
9226 return getInput(btnM, false, true);
9227 }
9228 bool DrunkcLbtn()
9229 {
9230 return getInput(btnL, false, true);
9231 }
9232 bool DrunkcRbtn()
9233 {
9234 return getInput(btnR, false, true);
9235 }
9236 bool DrunkcPbtn()
9237 {
9238 return getInput(btnP, false, true);
9239 }
9240
9241 bool DrunkrUp()
9242 {
9243 return getInput(btnUp, true, true);
9244 }
9245 bool DrunkrDown()
9246 {
9247 return getInput(btnDown, true, true);
9248 }
9249 bool DrunkrLeft()
9250 {
9251 return getInput(btnLeft, true, true);
9252 }
9253 bool DrunkrRight()
9254 {
9255 return getInput(btnRight, true, true);
9256 }
9257 6081285 bool DrunkrAbtn()
9258 {
9259 6081285 return getInput(btnA, true, true);
9260 }
9261 6098106 bool DrunkrBbtn()
9262 {
9263 6098106 return getInput(btnB, true, true);
9264 }
9265 71669 bool DrunkrEx1btn()
9266 {
9267 71669 return getInput(btnEx1, true, true);
9268 }
9269 71662 bool DrunkrEx2btn()
9270 {
9271 71662 return getInput(btnEx2, true, true);
9272 }
9273 bool DrunkrEx3btn()
9274 {
9275 return getInput(btnEx3, true, true);
9276 }
9277 bool DrunkrEx4btn()
9278 {
9279 return getInput(btnEx4, true, true);
9280 }
9281 bool DrunkrSbtn()
9282 {
9283 return getInput(btnS, true, true);
9284 }
9285 bool DrunkrMbtn()
9286 {
9287 return getInput(btnM, true, true);
9288 }
9289 6688759 bool DrunkrLbtn()
9290 {
9291 6688759 return getInput(btnL, true, true);
9292 }
9293 6685284 bool DrunkrRbtn()
9294 {
9295 6685284 return getInput(btnR, true, true);
9296 }
9297 bool DrunkrPbtn()
9298 {
9299 return getInput(btnP, true, true);
9300 }
9301
9302 9337 void eat_buttons()
9303 {
9304 9337 getInput(btnA, true, false, true);
9305 9337 getInput(btnB, true, false, true);
9306 9337 getInput(btnS, true, false, true);
9307 9337 getInput(btnM, true, false, true);
9308 9337 getInput(btnL, true, false, true);
9309 9337 getInput(btnR, true, false, true);
9310 9337 getInput(btnP, true, false, true);
9311 9337 getInput(btnEx1, true, false, true);
9312 9337 getInput(btnEx2, true, false, true);
9313 9337 getInput(btnEx3, true, false, true);
9314 9337 getInput(btnEx4, true, false, true);
9315 9337 }
9316
9317 // Is true for the _first frame_ of a key press.
9318 // But! it is possible that a script manually sets the value of KeyPress,
9319 // in which case it will be restored to the "true" value based on `key_current_frame`
9320 // and `key_previous_frame` on the next frame.
9321 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9322 {
9323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9325 {
9326 case KEY_F7:
9327 case KEY_F8:
9328 case KEY_F9:
9329 return KeyPress[k];
9330
9331 default:
9332
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 return KeyPress[k] && !disabledKeys[k];
9333 }
9334 14 }
9335
9336 // Is true for _every frame_ a key is held down.
9337 // But! it is possible that a script manually sets the value of KeyInput,
9338 // in which case it will be restored to the "true" value based on `key_current_frame`
9339 // on the next frame.
9340 bool zc_getkey(int32_t k, bool ignoreDisable)
9341 {
9342 if(ignoreDisable) return KeyInput[k];
9343 switch(k)
9344 {
9345 case KEY_F7:
9346 case KEY_F8:
9347 case KEY_F9:
9348 return KeyInput[k];
9349
9350 default:
9351 return KeyInput[k] && !disabledKeys[k];
9352 }
9353 }
9354
9355 // Reads (and then clears) the current frame key state directly.
9356 // Scripts can also modify `key_current_frame`.
9357 303 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9358 {
9359
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 301 times.
303 if(zc_getrawkey(k, ignoreDisable))
9360 {
9361 2 _key[k]=key[k]=key_current_frame[k]=0;
9362 2 return true;
9363 }
9364 301 _key[k]=key[k]=key_current_frame[k]=0;
9365 301 return false;
9366 303 }
9367
9368 // Reads the current frame key state directly.
9369 // Scripts can also modify `key_current_frame`.
9370 63243068 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9371 {
9372
2/2
✓ Branch 0 taken 53957403 times.
✓ Branch 1 taken 9285665 times.
63243068 if(ignoreDisable) return key_current_frame[k];
9373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9285665 times.
9285665 switch(k)
9374 {
9375 case KEY_F7:
9376 case KEY_F8:
9377 case KEY_F9:
9378 return key_current_frame[k];
9379
9380 default:
9381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9285665 times.
9285665 return key_current_frame[k] && !disabledKeys[k];
9382 }
9383 63243068 }
9384
9385 // Only used for a handful of keys, like tilde and Function keys.
9386 // This state is never read within the game.
9387 // It exists so that all keyboard input still functions during replay,
9388 // without inadvertently doing things like toggling throttling if the player
9389 // presses ~
9390 9285637 bool zc_get_system_key(int32_t k)
9391 {
9392 9285637 return key_system[k];
9393 }
9394
9395 // True for the _first_ frame of a key press.
9396 83570733 bool zc_read_system_key(int32_t k)
9397 {
9398 83570733 return key_system_press[k];
9399 }
9400
9401 1179275899 bool is_system_key(int32_t k)
9402 {
9403
2/2
✓ Branch 0 taken 1095705166 times.
✓ Branch 1 taken 83570733 times.
1179275899 switch (k)
9404 {
9405 case KEY_BACKQUOTE:
9406 case KEY_CLOSEBRACE:
9407 case KEY_END:
9408 case KEY_HOME:
9409 case KEY_OPENBRACE:
9410 case KEY_PGDN:
9411 case KEY_PGUP:
9412 case KEY_TAB:
9413 case KEY_TILDE:
9414 83570733 return true;
9415 }
9416 1095705166 return is_Fkey(k);
9417 1179275899 }
9418
9419 9285637 void update_system_keys()
9420 {
9421
2/2
✓ Branch 0 taken 1179275899 times.
✓ Branch 1 taken 9285637 times.
1188561536 for (int32_t q = 0; q < 127; ++q)
9422 {
9423
2/2
✓ Branch 0 taken 194998377 times.
✓ Branch 1 taken 984277522 times.
1179275899 if (!is_system_key(q))
9424 984277522 continue;
9425
9426 194998377 key_system[q] = key[q];
9427
1/2
✓ Branch 0 taken 194998377 times.
✗ Branch 1 not taken.
194998377 key_system_press[q] = key_system[q] && !key_system_previous[q];
9428 194998377 key_system_previous[q] = key_system[q];
9429 194998377 }
9430 9285637 }
9431
9432 10388948 void update_keys()
9433 {
9434
2/2
✓ Branch 0 taken 1319396396 times.
✓ Branch 1 taken 10388948 times.
1329785344 for (int32_t q = 0; q < 127; ++q)
9435 {
9436 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9437
1/2
✓ Branch 0 taken 1319396396 times.
✗ Branch 1 not taken.
1319396396 if (!replay_is_replaying())
9438 key_current_frame[q] = key[q];
9439
9440
2/2
✓ Branch 0 taken 1309610755 times.
✓ Branch 1 taken 9785641 times.
1319396396 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9441 1319396396 KeyInput[q] = key_current_frame[q];
9442 1319396396 key_previous_frame[q] = key_current_frame[q];
9443 1319396396 }
9444 10388948 }
9445
9446 bool zc_disablekey(int32_t k, bool val)
9447 {
9448 switch(k)
9449 {
9450 case KEY_F7:
9451 case KEY_F8:
9452 case KEY_F9:
9453 return false;
9454
9455 default:
9456 disabledKeys[k] = val;
9457 return true;
9458 }
9459 }
9460
9461 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9462 {
9463 timer=timer;
9464 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9465 }
9466